Image Optimization for the Web: Formats, Sizing & Delivery

Guide · Updated 2026-08-01 · Yexla Team

Images are most of the web's weight. Getting them right is the single highest-leverage performance work on most sites — and it's four decisions: format, dimensions, quality, delivery.

1. Format

FormatBest forNotes
AVIFPhotos, everything modernSmallest; encode support varies — see our AVIF converter
WebPPhotos & graphics, wide support~30% smaller than JPG; the safe modern default
JPGPhotos, maximum compatibilityQuality 75–85 is the sweet spot
PNGScreenshots, transparency, sharp edgesLossless; huge for photos — avoid
SVGIcons, logos, illustrationsVector — see SVG optimization

Practical pattern: <picture> with AVIF → WebP → JPG fallbacks, or simply ship WebP everywhere modern.

2. Dimensions

Never ship pixels the layout will throw away. A 4000px camera photo in a 800px column wastes ~90% of its bytes. Resize to the largest displayed size × device pixel ratio (2× covers most screens) — our resizer and srcset handle the rest:

<img srcset="hero-800.webp 800w, hero-1600.webp 1600w"
     sizes="(max-width: 900px) 100vw, 800px" src="hero-800.webp" alt="…">

3. Quality

Quality 80 JPG/WebP is visually indistinguishable from 100 for most photos at a fraction of the size. Compare live in the image compressor — go as low as the image tolerates, not a fixed number.

4. Delivery

Lazy-load below-the-fold images (loading="lazy"), but never the LCP hero — mark that fetchpriority="high". Always set width/height (or aspect-ratio) to prevent layout shift. Serve via CDN with far-future caching.

Frequently asked questions

Which image format is best for websites?

WebP is the practical default (30% smaller than JPG, universal support); AVIF is smaller still where encoding is available; PNG only for transparency and UI screenshots; SVG for vectors.

What JPG quality should I use?

75–85 for photos. Below ~70 artifacts appear in gradients and skin; above ~85 file size climbs with no visible gain.

Does lazy loading help Core Web Vitals?

Yes for below-fold images — but lazy-loading your LCP hero image hurts. Load the hero eagerly with fetchpriority=high, lazy-load the rest.