Core Web Vitals (Part 5): Images and Media Without the Performance Tax
Build a modern image and media pipeline with responsive images, AVIF/WebP, sizing, lazy loading, priority hints, video posters, CDN transforms and performance-safe embeds.

Images are easy to blame for slow websites because they are visible and often large.
They also deserve the attention. A page can ship beautifully engineered JavaScript and still waste several megabytes downloading oversized photography, off-screen carousels and third-party embeds nobody has looked at yet.
But “compress your images” is not an image strategy.
A production media pipeline needs to answer several different questions:
- what dimensions will this asset actually be displayed at?
- which format is appropriate?
- what quality level is visually acceptable?
- when should it be requested?
- how important is it compared with other resources?
- can its space be reserved before it arrives?
- does the user need the asset at all?
Get those decisions right and images can be rich without dominating LCP, bandwidth or CLS.
Start with dimensions, not format
The easiest byte to save is the pixel you never send.
If a card displays an image at roughly 360 pixels wide, serving a 2400-pixel source to every device is wasteful even if the file is AVIF.
Create multiple derivatives and let the browser choose:
<img
src="/media/product-800.webp"
srcset="
/media/product-400.webp 400w,
/media/product-800.webp 800w,
/media/product-1200.webp 1200w
"
sizes="(min-width: 900px) 33vw, 100vw"
width="1200"
height="800"
loading="lazy"
alt="Blue trail running shoe"
>
The srcset says what candidates exist. sizes tells the browser approximately how wide the image will render under different conditions.
If sizes lies, selection suffers.
A common mistake is putting sizes="100vw" on every image. A three-column desktop card is not 100% of the viewport width.
DPR means displayed CSS pixels are not the whole story
A 400 CSS-pixel image on a high-density screen may benefit from an 800-pixel resource.
That does not justify serving the largest original to everybody. It means your candidate set should give the browser sensible options for both layout width and device pixel density.
The browser is good at choosing when you give it accurate information.
Use <picture> when you genuinely need art direction or format control
srcset handles resolution selection well. <picture> becomes useful when the image itself should change.
For example, desktop might use a wide crop while mobile needs a portrait crop:
<picture>
<source
media="(max-width: 640px)"
srcset="/hero-mobile-640.avif 640w, /hero-mobile-960.avif 960w"
>
<img
src="/hero-desktop-1280.avif"
srcset="/hero-desktop-1280.avif 1280w, /hero-desktop-1920.avif 1920w"
width="1920"
height="900"
fetchpriority="high"
alt="Developer reviewing a SiteTidy audit"
>
</picture>
Art direction is not the same as “generate ten formats because we can”. Keep the pipeline maintainable.
AVIF, WebP, JPEG, PNG and SVG each have a job
AVIF
Often excellent for photographic imagery at low transfer sizes. Encoding can be more computationally expensive, which is usually a build/CDN concern rather than an end-user problem.
WebP
A strong general-purpose modern raster format with broad support and often excellent size/quality trade-offs.
JPEG
Still a viable fallback/source format for photography and widely interoperable, though modern delivery pipelines can often do better.
PNG
Useful where lossless raster detail or alpha behaviour warrants it. Frequently overused for large photographic screenshots.
SVG
Ideal for many logos, icons, diagrams and vector illustrations. It scales without generating a family of raster sizes.
Format choice should be based on the asset, not fashion.
A detailed UI screenshot with tiny text may tolerate compression differently from a soft-focus background photograph.
Automate derivatives instead of hand-editing assets
A site with hundreds or thousands of images should not depend on somebody remembering to export five sizes from Photoshop.
Build an image pipeline.
At upload/build/CDN-transform time, generate sensible variants such as:
400w
800w
1200w
1600w
and modern encodings where useful.
Then your CMS/component can emit correct markup automatically.
This is where image CDNs can be valuable: resize, crop and encode close to delivery while caching the resulting derivative.
But put guardrails around dynamic transformation APIs. Unlimited arbitrary dimensions can destroy cache efficiency and create operational cost.
The hero image and gallery image should not share loading rules
The browser should not treat every image equally.
Likely LCP image
- load eagerly;
- make it discoverable early;
- consider
fetchpriority="high"; - do not lazy-load it;
- size it appropriately;
- preload only if discovery otherwise occurs too late.
Below-the-fold content
loading="lazy"is usually appropriate;- keep dimensions/aspect ratio so space is reserved;
- do not give it high fetch priority.
Far-off carousel slides
Ask whether they need loading at all before the user approaches/interacts with the carousel.
Downloading eight 1600-pixel slides during initial load is not “smooth carousel UX”. It is often wasted bandwidth competing with the content the user can actually see.
Native lazy loading is usually the first choice
For normal images and iframes:
<img loading="lazy" ...>
<iframe loading="lazy" ...></iframe>
is preferable to maintaining a custom IntersectionObserver lazy-loader solely for basic loading behaviour.
Custom logic can still be justified when you need more control — for example prewarming content before it enters the viewport or coordinating complex components.
Do not reinvent browser features without a reason.
Reserve media space to protect CLS
Every raster image should normally expose dimensions or an aspect ratio.
<img
src="/article-chart.webp"
width="1400"
height="900"
loading="lazy"
alt="Performance chart"
>
For embeds:
.embed-shell {
aspect-ratio: 16 / 9;
}
.embed-shell iframe {
width: 100%;
height: 100%;
border: 0;
}
Loading later is fine. Rebuilding the layout when the content arrives is not.
Background images deserve suspicion
CSS backgrounds are convenient for decorative imagery, but they have trade-offs:
- discovery depends on CSS;
- responsive selection can become less obvious;
- semantic alt text is unavailable because the image is decorative by definition;
- preload/fetch priority handling requires more care.
If an image conveys content, prefer actual image markup.
If it is purely decorative, a background may be exactly right.
Do not turn meaningful hero content into CSS just because the designer called it a background.
Video can dwarf every other optimisation
Autoplay hero video is one of the fastest ways to make a landing page expensive.
Ask whether motion genuinely earns its transfer and CPU cost.
If you use video:
- provide a lightweight poster;
- avoid preloading the entire video when it is not immediately necessary;
- provide multiple encodings/resolutions where the platform allows it;
- respect reduced-motion preferences where appropriate;
- avoid autoplay with audio;
- consider mobile/network behaviour;
- lazy-initialise below-the-fold players.
A poster can provide the visual design immediately while the heavier media waits for user intent.
preload on <video> is a product decision
For HTML video:
<video
controls
preload="metadata"
poster="/media/demo-poster.webp"
>
<source src="/media/demo.webm" type="video/webm">
</video>
preload="metadata" can be a sensible middle ground when you want duration/dimensions without eagerly fetching the whole asset.
preload="none" is useful when the user may never play it.
auto is a hint that downloading more is acceptable — which can be expensive across several videos.
Measure the actual browser/network behaviour rather than assuming the attribute guarantees an exact byte policy.
YouTube and other embeds: load the player when the user needs it
A full third-party video iframe can bring substantial JavaScript, connection and tracking cost.
A common performance pattern is a facade:
- render a local thumbnail/poster and play button;
- reserve the final player’s dimensions;
- create the real iframe only after user interaction.
The page initially pays for an image and small amount of local UI rather than an entire embedded application.
This technique is useful for maps, chat widgets and other heavy embeds too.
Be transparent about what happens when the user activates the third party, particularly where privacy/consent requirements apply.
Do not decode and render giant images just because transfer is compressed
A highly compressed file can still represent a huge decoded bitmap.
A 6000 × 4000 image contains 24 million pixels. Even if network compression makes the file surprisingly small, decoding and memory usage are not free.
Generate derivatives close to the dimensions the UI needs.
This matters especially on memory-constrained mobile devices and image-heavy feeds.
Product zoom needs a different strategy from the product card
Ecommerce often needs both:
- a lightweight card/listing image;
- a high-resolution zoomable image.
Do not make every visitor download the zoom source to render a 280-pixel card.
Load the appropriate candidate initially, then fetch higher-resolution media when the user opens zoom/gallery functionality.
Performance architecture should follow user intent.
Image SEO and accessibility are not performance enemies
Optimisation does not mean stripping useful semantics.
Keep meaningful alt text for content images. Use empty alt="" for decorative images in markup where appropriate. Preserve useful filenames/context where they fit your content system.
Do not replace a meaningful <img> with a CSS background merely to hide it from a performance audit.
Good markup usually makes performance easier, not harder.
A practical media audit
For each major page template, inventory:
| Question | Why it matters |
|---|---|
| What is the LCP media element? | It needs different priority rules |
| Largest transferred images? | Finds obvious byte waste |
| Natural vs rendered dimensions? | Finds oversized sources |
| Images loaded below the fold? | Finds eager-loading waste |
| Missing dimensions/aspect ratios? | CLS risk |
| Duplicate/unused carousel media? | Bandwidth competition |
| Third-party embeds? | Often large JS/network cost |
| Video preload behaviour? | Can dominate page weight |
| Cache headers/CDN transforms? | Repeat-visit and delivery efficiency |
Then fix systematic component/pipeline problems rather than editing individual pages forever.
Common image optimisation mistakes
Converting everything to AVIF and declaring victory
Dimensions, loading priority and discovery still matter.
Lazy-loading every image
Do not lazy-load the likely LCP image.
Using one giant source because CSS makes it responsive
CSS changes display dimensions, not downloaded pixels.
Generating dozens of nearly identical candidates
More variants are not automatically better. Balance selection quality against cache/build complexity.
Serving screenshots as PNG by habit
Test WebP/AVIF or other appropriate encodings; UI screenshots can be surprisingly large.
Preloading an image and lazy-loading the same image
Those instructions express contradictory intent.
Loading third-party players immediately
Use facades when immediate functionality is not required.
Audit the delivered page, not the source asset folder
SiteTidy can help expose page-level performance and asset issues. Use that alongside DevTools network traces to see what users actually download and when.
A production media policy
A useful default policy looks something like this:
- originals are retained outside the public critical path;
- responsive derivatives are generated automatically;
- modern encodings are used where they improve the asset;
- components emit accurate
srcsetandsizes; - image dimensions/aspect ratios are always known;
- the likely LCP image is eager/high-priority where justified;
- below-fold images use native lazy loading;
- carousels do not eagerly fetch every high-resolution slide;
- video uses posters and conservative preload rules;
- heavy third-party embeds use facades where practical;
- CDN caching and transformations are bounded and observable;
- field metrics verify that changes improve actual user experience.
The goal is not the smallest possible page at any visual cost. It is to make every expensive media request earn its place in the user’s experience.
Part 6 moves to the other common heavyweight: JavaScript — bundles, hydration, third parties and how client-side work affects both loading and INP.
