On most business websites, images are the majority of the page weight and the reason the largest element takes so long to paint. Getting them right is the single highest value performance job, and it is mostly decisions rather than code.
Pick the format by what the image is
Photographs: AVIF, with WebP behind it. AVIF is typically 30 to 50 per cent smaller than WebP at the same quality. Browser support is now good, and the fallback costs nothing if your build handles it.
Logos, icons and diagrams: SVG. Vector, tiny, sharp at every size, and restyleable in CSS. Never export a logo as a PNG unless it has a photographic element in it.
Anything needing transparency with soft edges: WebP or PNG. AVIF handles transparency too, but PNG remains the safe fallback.
Screenshots: WebP. Text in screenshots survives WebP compression better than it survives aggressive JPEG.
JPEG and PNG still work everywhere. If your tooling cannot produce modern formats, well compressed JPEG at quality 75 to 82 is perfectly acceptable; it is the uncompressed 4 MB export that is the problem.
Export at the size it is actually shown
The most common waste: a 4000 pixel wide photograph displayed in a 600 pixel box. The browser downloads all of it and throws most of it away.
Rule of thumb: export at twice the largest size the image is displayed at, to stay sharp on high density screens, and no larger. A card image shown at 400 pixels wide needs an 800 pixel file.
Serve different sizes to different screens
A phone should not download the desktop hero. The srcset attribute lets the browser choose:
<img
src="/hero-800.webp"
srcset="/hero-480.webp 480w, /hero-800.webp 800w, /hero-1600.webp 1600w"
sizes="(max-width: 700px) 100vw, 800px"
width="1600" height="900" alt="..."
/>
Most frameworks generate this for you from a single source file. Astro, Next.js and Webflow all do it; the thing to check is that it is switched on.
Always set width and height
Without them the browser does not know how much space to reserve, so the page jumps as each image loads. That jump is measured as Cumulative Layout Shift and it is the most irritating thing a page can do while someone is reading it. Set the attributes to the file’s real dimensions and let CSS handle the display size.
Load the right things first
Your hero image should load eagerly and, ideally, be preloaded. Everything below the fold should be loading="lazy". Getting this backwards, which happens when lazy loading is applied globally, delays the one image that affects your Largest Contentful Paint score.
Do not ship what nobody sees
Decorative background images, carousels where only the first slide is ever seen, and galleries loaded in full on page load are all pure cost. If an image only appears after an interaction, load it after the interaction.