Why reach for HTML before a loading spinner component?
Many loading, disabled, and pending states are rebuilt in JavaScript even though the browser already gives you useful primitives. Native HTML will not cover every async flow, but using the right element or attribute often means better keyboard behavior, simpler state management, and fewer accessibility gaps.

The important part is matching the primitive to the state. A task that is advancing is different from a gauge reading. A region that is changing is different from a notification. An offscreen image is different from an image that should decode without blocking rendering.

Choose the right native state
| State type | Use | Visual effect? | Assistive tech impact | Typical scenario | Do not use for |
|---|---|---|---|---|---|
| Task progress | <progress> |
Yes, browser-provided bar | Exposes progress semantics | File upload, multi-step form save | Static measurements such as disk space |
| Scalar measurement | <meter> |
Yes, browser-provided gauge | Exposes value/min/max semantics | Storage quota, password strength, rating scale | An operation that will complete later |
| Inactive subtree | inert |
No built-in visual change | Removes elements from tab and accessibility tree | Modal background, locked form section | Hiding temporary helper text or dimming a card |
| Region being updated | aria-busy="true" |
No | Marks content as temporarily changing | Refreshing a product list after a filter | Announcing success or failure |
| Offscreen image deferral | loading="lazy" |
No loading UI | Usually none directly | Below-the-fold article images | Hero images or print-critical images |
| Non-blocking image decode | decoding="async" |
No loading UI | Usually none directly | Dynamically swapped images, large galleries | Forcing strict synchronous presentation |
| Unavailable control | disabled |
Browser styling varies | Disabled controls can be removed from focus/accessibility tree | A permanently unavailable action | Hiding validation problems from screen reader users |
Use progress for completion, not arbitrary busy work
<progress> represents the completion status of a task. Use the determinate form only when you know the current value and maximum.
<label for="upload">Uploading contract.pdf</label>
<progress id="upload" max="100" value="62">62%</progress>
<p>62% uploaded — do not close this tab.</p>
If you cannot know how long the task will take, omit value for an indeterminate bar.
<label for="save">Saving changes</label>
<progress id="save">Loading…</progress>
Do not fake progress by racing a timer toward 99%. It looks reassuring until the real request fails or stalls. If the task has no measurable progress, say that plainly and provide a way to retry or cancel when possible.
Progress versus meter
<meter> is a gauge, not a task indicator. It describes a current value within a known range, optionally with low, high, and optimum thresholds.
<label for="storage">Storage used</label>
<meter id="storage" value="820" min="0" max="1000" low="700" high="900" optimum="500">
820 MB of 1 GB used
</meter>
Use progress for “file is uploading.” Use meter for “the account is using 82% of its quota.” Swapping them makes the UI communicate the wrong idea.
meter has broad support in modern browsers, but older engines may show only fallback text. Treat the browser gauge as progressive enhancement: keep a visible text value, and do not rely on color alone to convey warning levels.
Disable interaction carefully
Prefer inert for a whole container
The inert attribute makes a subtree non-interactive: it is removed from tab order, clicks do not activate controls, and it is excluded from the accessibility tree. That makes it useful for the background behind an open modal or a locked section of a multi-step flow.
<main inert="" class="is-locked">
<h2>Checkout</h2>
<form>
<!-- form controls -->
</form>
</main>
You may add visual styling, but remember that the attribute itself does the accessibility and interaction work.
<style>
.is-locked {
opacity: 0.55;
}
</style>
I would not add pointer-events: none just to make the demo look stronger. inert already prevents interaction; pointer-events only changes hit testing and can make debugging more confusing. Visual dimness communicates state; it is not the semantic lock.
Modern Chrome, Edge, Firefox, and Safari support inert. For older browsers, use a polyfill where you can and keep a robust modal pattern: move focus into the dialog, trap tab while it is open, and return focus on close.
disabled buttons have real pitfalls
A disabled submit button can prevent duplicate submits, but it can also make the interface harder to understand. Screen readers may not announce the disabled control, keyboard users cannot focus it to discover why it is unavailable, and users can lose context when the button suddenly appears dead.
<button type="submit" disabled>Save changes</button>
For invalid forms, a better pattern is often to leave the button enabled, then show validation errors on submit. If the action is genuinely unavailable, explain why with visible text.
<button type="submit">Save changes</button>
<p>Add a billing email before saving.</p>
Use aria-disabled="true" if you need a focusable control that communicates disabled semantics while your script handles the blocked action. Do not combine that with no explanation.
Mark changing regions with aria-busy
aria-busy="true" tells assistive technologies that a region is currently being updated and that the intermediate DOM may be incomplete. Set it back to false when the update is finished.
<section id="results" aria-busy="true" aria-live="polite">
<h2>Search results</h2>
<p>Updating results…</p>
</section>
The common mistake is expecting aria-busy to announce messages. It does not create a live region by itself, and it does not say “loading,” “complete,” or “error.” Those messages need visible text and an appropriate live-region strategy.
<section id="results" aria-live="polite">
<h2>Search results</h2>
<p id="status" role="status">12 products found.</p>
</section>
Use aria-live="polite" for ordinary completion messages. Reserve assertive for urgent errors that need immediate attention. Keep the region stable; rapidly replacing live text can produce noisy or incomplete announcements.
Lazy-load images that the user may not need yet
loading="lazy" tells the browser it may defer fetching an image until the user is likely to scroll near it. This saves bandwidth and can reduce initial page weight for long articles, product lists, comment threads, and galleries.
<img
src="article-diagram.avif"
alt="Flowchart showing the checkout validation steps"
width="960"
height="540"
loading="lazy"
>
Always include width and height, or another aspect-ratio technique. Otherwise, late image insertion causes layout shifts and scroll jumps. Add a background color or placeholder in CSS if empty image areas look unfinished.
<img
srcset="small.avif 480w, large.avif 960w"
sizes="(max-width: 600px) 100vw, 50vw"
src="large.avif"
alt="Comparison of progress and meter components"
width="960"
height="540"
loading="lazy"
>
Do not lazy-load the main product photo, a hero image, or an image visible in the first viewport. The browser may delay something the user immediately needs. Also avoid lazy loading every image in a horizontally scrolling carousel without testing; the distance calculation is tuned mainly for normal scrolling.
Support is good in current Chromium, Firefox, and Safari. The safe progressive enhancement is simple: browsers that ignore the attribute load images normally, so there is no functional break. Use it as an optimization, not as a prerequisite for displaying content.
Use decoding="async" for smoother rendering
decoding="async" tells the browser that decoding this image may happen asynchronously so image processing is less likely to block other rendering work. It controls how the browser decodes, not when it fetches.
<img
src="photo-large.avif"
alt="A detailed dashboard with several charts"
width="1200"
height="800"
decoding="async"
>
This is useful for large images, dynamically inserted thumbnails, or image swatches that change when a user selects a color. It can help keep scrolling and interaction smoother when many images are involved.
<img
src="jacket-side.avif"
alt="Jacket side view"
width="900"
height="1100"
decoding="async"
>
loading="lazy" versus decoding="async"
loading="lazy" is about network timing and whether an offscreen image should be fetched later. decoding="async" is about rendering and whether decoding can happen off the main rendering path. They answer different questions and can be combined.
<img
src="below-fold-photo.avif"
alt="Installation step shown below the first screen"
width="1000"
height="600"
loading="lazy"
decoding="async"
>
Do not use decoding="async" as a lazy-loading substitute. An eager image with async decoding can still be fetched immediately. Conversely, loading="lazy" does not promise asynchronous decode once the image arrives.
For a visible hero image, you may prefer decoding="async" without loading="lazy", or omit both if you need the most predictable presentation. For below-the-fold content, combining both is reasonable. Modern browsers support decoding="async"; unsupported browsers simply use their normal image decoding path.
A practical loading pattern
You can combine these primitives without building a heavy framework state. Mark the changing region, show a real progress element when progress is known, lock unrelated UI with inert, and report completion through visible text.
<form id="checkout">
<label for="file">Receipt file</label>
<input id="file" type="file">
<button type="submit">Upload and continue</button>
</form>
<section id="upload-status" aria-live="polite" hidden>
<label for="bar">Uploading receipt</label>
<progress id="bar" max="100">0%</progress>
<p id="message" role="status">Preparing upload…</p>
</section>
The small JavaScript you still need can focus on actual events: upload progress, success, failure, and toggling attributes. HTML carries the semantics, the browser supplies accessible controls, and your code stops pretending that every spinner needs to be invented from scratch.