Pull up a performance report for almost any site, look at the largest resources, and images will be at the top. The good news is that image optimization, unlike rewriting your JavaScript, is low-risk and shows results immediately.
Which format?
Three serious options. AVIF generally produces the smallest files, especially for photographic content with gradients and fine detail, at the cost of slower encoding. WebP is slightly larger but encodes fast and is excellent for flat graphics and logos. JPEG and PNG still make sense as fallbacks, but should not be your first choice.
The safe pattern is to offer several sources and let the browser pick the first one it understands:
<picture>
<source srcset="cover.avif" type="image/avif">
<source srcset="cover.webp" type="image/webp">
<img src="cover.jpg" alt="Descriptive text" width="1200" height="675">
</picture>
Size matters more than format
The classic mistake: shrinking a 3000px image to 600px with CSS and calling it done. The user still downloaded the large file. Use srcset and sizes to generate real variants so phones get small files and desktops get large ones. For most sites three widths — roughly 480, 960 and 1600 pixels — are enough.

Lazy load, but not everything
Add loading="lazy" to images below the fold so they are not fetched until needed. But never lazy-load the hero image. That image is usually the LCP element, and deferring it directly damages your score. Give it fetchpriority="high" instead.
Stop the layout from jumping
Every <img> should carry width and height attributes even when CSS controls the rendered size. The browser derives the aspect ratio from them and reserves the space in advance. Without it, text jumps once the image arrives — typically at the exact moment the user is tapping a link.
Take alt text seriously
Alt text is not an SEO field. It is what a screen reader user hears and what everyone sees when an image fails to load. Write a short, meaningful description rather than a keyword list. If the image is purely decorative, use alt="" so assistive technology skips it.
A short checklist
- Export at the largest size actually displayed, no larger.
- Produce AVIF and WebP; keep JPEG only as a fallback.
- Lazy-load below the fold, prioritize the hero.
- Always declare dimensions in the HTML.
- If you have an image CDN, let it handle format negotiation and resizing rather than building it by hand.


