Images often account for a large share of page bytes. Optimizing them requires more than converting every file to one modern format. The browser should receive an image that fits the rendered dimensions, has appropriate quality and does not delay critical content unnecessarily.
Choose formats by use case
WebP and AVIF can reduce file size for many photographic images, while SVG is suitable for scalable vector artwork when the source is trusted and sanitized appropriately. Keep a practical fallback strategy based on browser support and the site's content pipeline.
Serve responsive sizes
Use srcset and sizes so the browser can select a suitable image for the viewport and pixel density. Avoid sending a very large desktop image to a small mobile display. Generate a limited set of predictable widths rather than creating hundreds of near-duplicate variants.
Reserve layout space
Include width and height attributes or an aspect ratio so the browser can reserve space before the image loads. This reduces layout shifts and improves perceived stability. Lazy-load below-the-fold images, but do not lazy-load the primary image that is likely to be the page's LCP element.
Tune quality and inspect output
Use representative photographs and graphics to test compression settings. Review text, edges, gradients and transparency after conversion. Keep original source assets where future regeneration may be needed.
Checklist
- Generate a small, useful set of responsive widths.
- Use modern formats with sensible fallbacks.
- Set intrinsic dimensions or aspect ratio.
- Lazy-load only non-critical offscreen images.
- Review visual quality and actual transferred bytes.