Images are usually the largest bytes on a page and often the LCP element. A good setup has five parts. Modern formats (AVIF, then WebP, with a JPEG/PNG fallback). Responsive sizing with srcset/sizes so phones don't download desktop pixels. Correct loading priority (eager and fetchpriority="high" for the hero, loading="lazy" below the fold). Explicit dimensions to prevent CLS. And an image CDN or build pipeline so none of this depends on each engineer remembering it.
<picture>
<source type="image/avif"
srcset="/p/42-400.avif 400w, /p/42-800.avif 800w, /p/42-1600.avif 1600w"
sizes="(max-width: 700px) 100vw, 50vw">
<source type="image/webp"
srcset="/p/42-400.webp 400w, /p/42-800.webp 800w, /p/42-1600.webp 1600w"
sizes="(max-width: 700px) 100vw, 50vw">
<img src="/p/42-800.jpg" width="800" height="600"
alt="Blue running shoe, side view"
loading="lazy" decoding="async">
</picture>
srcset with w descriptors + sizes. The browser picks a candidate using the layout width you declare in sizes and the device pixel ratio. A wrong sizes (for example the default 100vw for a thumbnail) wastes bytes. Use x descriptors only for fixed-size images.<picture> with media is for art direction (a different crop on mobile), not just resolution switching.| Image | Attributes |
|---|---|
| LCP hero | no loading="lazy", fetchpriority="high", ideally in the server HTML |
| Above the fold, not LCP | default (eager) |
| Below the fold | loading="lazy", decoding="async" |
| Carousels' hidden slides | loading="lazy" or fetchpriority="low" |
Native lazy loading uses generous distance thresholds, so images usually arrive before the user scrolls to them. Always pair it with width/height or aspect-ratio.
Accept header. Send Vary: Accept or use distinct URLs so caches don't serve AVIF to a client that can't decode it.<Image> component that requires alt, width/height and sizes, and supports a priority prop for the hero.background-image for meaningful or LCP images. The preload scanner can't see it and there's no alt.sizes, so the browser assumes 100vw and downloads the biggest candidate.<video autoplay muted loop playsinline> with MP4/WebM instead.srcset candidate (layout width × DPR), and art direction vs resolution switching.fetchpriority, lazy loading only below the fold, and the effect on LCP.Spotted a mistake or a rights concern? Report an issue