A progressive image loader shows a small placeholder immediately, reserves the final image’s space, then fades in the full image after it has loaded (and, optionally, decoded). The browser should still handle responsive source selection and native lazy loading; a small JavaScript layer is only needed for the visual reveal or decode-before-reveal behavior.
What the loader should do
A robust implementation has four parts:
- Reserve the final geometry. Intrinsic
widthandheight, or an equivalent CSS aspect ratio, prevent layout shifts. - Paint a lightweight placeholder. Use a tiny version of the same image, a solid color, or another very small asset.
- Request the real image responsively. Let
srcsetandsizeschoose a candidate appropriate for the rendered slot. - Reveal the real image only when ready. A load event is sufficient for most pages;
decode()can avoid showing a decoded-after-paint flash on large images.
The placeholder is decorative. The informative alt text belongs on the real <img>, so assistive technology receives one meaningful image rather than two.
These principles align with the guidance on image performance and responsive images.
1. Add the image markup
This framework-neutral example keeps both layers in the same box. Replace the paths and alternative text with your own assets.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
<figure class="progressive-image" data-progressive>
<img
class="progressive-image__full"
src="/images/landscape-1200.jpg"
srcset="/images/landscape-480.jpg 480w,
/images/landscape-900.jpg 900w,
/images/landscape-1200.jpg 1200w"
sizes="(max-width: 600px) 100vw, 80vw"
width="1200"
height="800"
alt="A description of the landscape"
loading="eager"
decoding="async">
<span class="progressive-image__placeholder" aria-hidden="true"
style="background-image: url('/images/landscape-tiny.jpg')"></span>
</figure>
Keep a valid src fallback even when srcset is present. The browser uses the width descriptors and the sizes expression to select a suitable file; on a narrow screen it can avoid downloading the 1,200-pixel candidate.
Choose the loading mode for the image’s position
Use loading="lazy" for images that start well below the viewport. Do not apply it to the page’s likely largest contentful paint (LCP) image: deferring a visible image can make the main content appear later. For a genuinely critical image, fetchpriority="high" can provide an additional hint, but it is heuristic rather than a guarantee. A lazy image remains deferred even when given high priority. loading="eager" means normal eager queueing, not a priority boost.
See browser-level image lazy loading, Fetch Priority, and the responsive-image guidance for the browser’s loading and prioritization behavior.
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
2. Reserve space and layer the two images
.progressive-image {
position: relative;
display: block;
overflow: hidden;
aspect-ratio: 3 / 2;
background: #e8e8e8;
}
.progressive-image__full,
.progressive-image__placeholder {
position: absolute;
inset: 0;
width: 100%;
height: 100%;
}
.progressive-image__full {
object-fit: cover;
opacity: 0;
transition: opacity 180ms ease;
}
.progressive-image.is-loaded .progressive-image__full {
opacity: 1;
}
.progressive-image__placeholder {
background-size: cover;
filter: blur(14px);
transform: scale(1.05);
}
.progressive-image.is-loaded .progressive-image__placeholder {
opacity: 0;
transition: opacity 180ms ease;
}
@media (prefers-reduced-motion: reduce) {
.progressive-image__full,
.progressive-image__placeholder {
transition: none;
}
}
The CSS aspect ratio must match the source image’s ratio. When that ratio is known, the HTML dimensions are preferable because they communicate the intrinsic size to the browser before CSS is fully applied. Use either dimensions, an aspect ratio, or both consistently; do not let the placeholder and final image use different geometry.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Clear out junk files and repair common Windows errors3Fix the driver behind crashes, sound loss and screen glitchesobject-fit: cover crops both layers in the same way. Choose contain instead when the complete image must remain visible. The blur and slight scale hide the sharp edge that blur filters can otherwise expose; a solid background can be used when you do not want a second image request.
3. Reveal the full image with JavaScript
The following handler works for multiple figures, including images served from cache. It waits for decoding when that API is available and treats a decode rejection as a reason to reveal anyway rather than leaving the placeholder forever.
Rank #3
for (const figure of document.querySelectorAll("[data-progressive]")) {
const image = figure.querySelector("img");
const reveal = () => figure.classList.add("is-loaded");
const revealAfterDecode = () => {
if (typeof image.decode === "function") {
image.decode().then(reveal, reveal);
} else {
reveal();
}
};
if (image.complete && image.naturalWidth > 0) {
revealAfterDecode();
} else {
image.addEventListener("load", revealAfterDecode, { once: true });
image.addEventListener(
"error",
() => figure.classList.add("has-error"),
{ once: true }
);
}
}
complete covers an image that finished before the script attached its listener. Checking naturalWidth distinguishes a successfully loaded image from a broken request. The error class gives you a hook for a fallback style or message; define that state if a failed image should be visibly different from a still-loading one.
What happens without JavaScript?
The full <img> remains real content, but the CSS above keeps it transparent until a class is added. If users can reach the page with scripts disabled, add a no-script override so the image is visible:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
<noscript>
<style>
.progressive-image__full { opacity: 1; }
.progressive-image__placeholder { display: none; }
</style>
</noscript>
Alternatively, put a small inline rule or server-rendered “loaded” state in your no-JavaScript path. Do not make the placeholder the only meaningful representation of an image.
Rank #4
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Placeholder choices and their costs
| Approach | What the browser downloads | When it fits | Trade-off |
|---|---|---|---|
| Tiny same-image raster | A very small additional image plus the selected full candidate | You want a recognizable, blurred preview | Adds a request and bytes; keep the tiny asset genuinely small |
| Solid color | No placeholder image request | You prefer the lowest overhead or a designed background color | Provides no visual preview of the subject |
| Generated placeholder | Depends on your image pipeline | You already produce dominant-color or low-quality variants | Requires generation and storage or transformation logic |
There is no required placeholder encoding. The performance win comes from keeping the placeholder small and delivering an appropriately sized final candidate; a large “preview” can cancel the benefit.
Loading, decoding and priority: choose independently
These attributes solve different problems:
| Control | Purpose | Practical guidance |
|---|---|---|
loading |
Controls whether offscreen fetching is deferred | Lazy-load below-the-fold content; leave the likely LCP image non-lazy |
fetchpriority |
Hints relative network priority | Use high sparingly for a truly important image; it is not a guarantee |
decoding |
Expresses a preferred decode strategy | async is a reasonable preference for many non-blocking images |
decode() |
Lets script wait for decoding before revealing or inserting an image | Useful for large images when a decode-before-reveal transition is worth the extra state handling |
Native lazy loading can work without custom JavaScript. The progressive layer is for the visual transition and optional decode coordination, not a replacement for the browser’s image scheduler.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Accessibility and semantics
- Write useful
alttext for an image that conveys information. Usealt=""when it is purely decorative. - Keep the placeholder
aria-hidden="true"; it should not be announced as a second image. - Do not put the descriptive text only in a background image, because CSS backgrounds have no equivalent image alternative for screen readers.
- Respect
prefers-reduced-motion; the example removes the cross-fade rather than forcing animation.
These semantics are part of the responsive-image recommendations at web.dev.
Best Value
Testing and failure handling
- Test with an empty cache and a warm cache. The
completebranch must reveal cached images. - Throttle the network and scroll through below-the-fold images. Confirm that lazy images request only when approaching the viewport.
- Resize the viewport and inspect the selected
srcsetcandidate. The rendered slot described bysizesshould match the actual layout. - Block the full-size request. The
has-errorstate should not leave a permanent loading illusion; provide a fallback style or message appropriate to your design. - Disable JavaScript. The real image must still be available through your no-script rule or server-rendered fallback.
- Use a screen reader and keyboard-only navigation to verify that the placeholder is silent and the final image has the intended alternative text.
- Check the first viewport separately from article galleries. The likely LCP image should be discoverable early and should not be accidentally deferred.
Reserve space with dimensions or aspect ratio in every state. Progressive presentation improves perceived waiting, but reducing the final transfer size is what gets the fully rendered image to the reader sooner; the image-performance guidance covers that broader optimization.
When to use an image transformation service
If creating 480-, 900- and 1,200-pixel variants manually is burdensome, an image CDN or transformation service can generate and deliver those candidates. Evaluate it against your existing pipeline by comparing variant generation, delivery behavior, integration effort and cache strategy. Keep the HTML contract the same—valid src, accurate srcset/sizes, intrinsic dimensions and accessible alt text—so changing the backend does not change the loader’s semantics.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

