Skip to the content.

Image optimization

Decide per image

Image Format Loading
Logos, icons, illustrations with flat colors SVG (optimized with SVGO), or an icon font/sprite Inline or <img>
Photos AVIF with WebP and JPEG fallback (or WebP + JPEG) srcset + sizes
Screenshots / UI with text WebP or PNG (lossless), AVIF if it keeps text crisp at your quality setting srcset
Animated GIF Convert to a muted, looping <video> (MP4/WebM) or animated WebP/AVIF <video autoplay muted loop playsinline>
Hero / LCP image Best format above, preloaded by being in the HTML fetchpriority="high", never lazy

Markup

<!-- LCP hero: eager, high priority, explicit dimensions -->
<img src="/img/hero-1200.jpg"
     srcset="/img/hero-640.avif 640w, /img/hero-1200.avif 1200w, /img/hero-1920.avif 1920w"
     sizes="100vw" width="1920" height="1080" alt="..." fetchpriority="high">

<!-- below the fold: lazy -->
<img src="/img/card-480.webp" srcset="/img/card-480.webp 480w, /img/card-960.webp 960w"
     sizes="(min-width: 64rem) 30vw, 90vw" width="960" height="640" alt="..." loading="lazy" decoding="async">

<!-- format fallbacks -->
<picture>
  <source type="image/avif" srcset="/img/team.avif">
  <source type="image/webp" srcset="/img/team.webp">
  <img src="/img/team.jpg" width="1200" height="800" alt="The team at the 2026 offsite">
</picture>

Rules:

Build or CDN

Prefer automation over hand-exporting:

Quality starting points: AVIF around 50-65, WebP around 75-80, JPEG around 75-82; check visually on the image types that matter (faces, gradients, text).

Audit

Report savings as bytes before/after and LCP before/after, not just “optimized”.