Lesson 4 of 9 · 26m
Image Strategy: Bytes, Dimensions, and the Hero You Actually See
Choose formats, responsive sizes, priorities, lazy loading, and decoding behavior deliberately so images improve LCP instead of destroying it.
Images are usually the largest bytes on a content-heavy page and the most visible performance failure. They are also where teams make the strangest tradeoffs: compressing a decorative thumbnail to perfection while shipping a four-megabyte hero through CSS, then wondering why LCP is terrible. Treat images as a delivery system: selection, encoding, dimensions, priority, cache behavior, and visual stability all matter.
Start with the LCP candidate
Find what the browser chooses as the largest contentful paint. If it is an image, ask four questions before touching compression:
Is the image necessary at that size?
Is it discovered early enough?
Is it served at the correct dimensions?
Is it prioritized ahead of less important work?A perfectly encoded image discovered at 1.5 seconds is still a slow LCP. A lightweight but visually irrelevant image can still be a design mistake if it pushes meaningful content down.
Responsive images are a bandwidth contract
Use srcset and sizes so the browser can select a plausible candidate for the viewport and density:
<img src="/images/warehouse-1200.avif"
srcset="/images/warehouse-800.avif 800w, /images/warehouse-1200.avif 1200w, /images/warehouse-1800.avif 1800w"
sizes="(max-width: 700px) 100vw, 66vw"
width="1200" height="800" alt="Warehouse robots moving inventory" fetchpriority="high">The browser, not your instinct, chooses based on viewport width and device pixel ratio. Your job is to provide realistic candidates and accurate sizes. Wrong sizes can be worse than none because the browser confidently selects the wrong asset.
Format selection is practical, not ideological
AVIF excellent compression, especially photos; slower encoding
WebP broad support, good compression, safer generation cost
JPEG universal fallback, often larger
PNG lossless UI/screenshots, often wasteful for photos
SVG vector art and icons, not photographsDo not transcode every asset on every request. Build a pipeline with content-hashed outputs and cache immutable variants. If a CDN image optimizer is involved, understand whether it negotiates by Accept, by URL extension, or by query parameters, because cache keys and debugging depend on that behavior.
Lazy-load below the fold, not the hero
Native lazy loading is appropriate for images the user may never reach:
<img src="/images/detail-1.webp" loading="lazy" decoding="async" width="900" height="600" alt="Control panel detail">Never lazy-load the LCP hero image. You are telling the browser to deprioritize the one element the metric waits for. Also be careful with carousels: the visible first slide is not below the fold merely because later slides exist.
Reserve space and decode off the critical path
Width and height prevent CLS. decoding="async" gives the browser permission not to serialize expensive decode work into presentation. Neither replaces correct sizing. For art-directed crops use <picture>, but remember that every source is another pipeline to maintain and test.
<picture>
<source media="(max-width: 700px)" srcset="/images/hero-mobile.avif">
<img src="/images/hero-desktop.avif" width="1600" height="900" alt="...">
</picture>CSS background heroes are discovered late and expose less priority control; use an actual <img> when the image matters to LCP.
Field notes
- Compression quality below the point of visible artifacts is wasted engineering; compare images at final rendered size, not in a file manager.
- Content management systems need guardrails. Authors will upload a 6000-pixel PNG named
final-final.pngunless the pipeline constrains them. - A CDN optimizer can create cache fragmentation if every device receives a different URL or query combination.
- Do not use transparent placeholders or tiny blurred images as an excuse to delay the real hero; progressive enhancement should not become deliberate LCP delay.
Was this lesson helpful?