Image optimization for new colleagues
Many descriptions of image optimization begin by explaining the vocabulary and lose readers halfway. This one takes it the other way: the central idea first, the details after it.
What It is
Responsive images give the browser a choice of sizes of the same picture with srcset and sizes, so a phone fetches a narrow file and a wide screen a larger one, instead of everyone downloading the full-size original.
Under the Surface
Modern codecs squeeze photographs far better than JPEG ever did, so the similar-looking image downloads faster on busy networks. Before tuning fonts, check the images: for many pages they weigh more than everything else combined.
<img src="/img/product-400.webp"
srcset="/img/product-400.webp 400w, /img/product-800.webp 800w"
sizes="(max-width: 400px) 100vw, 400px"
width="400" height="320"
loading="lazy" decoding="async" alt="">
What We Do with It
The srcset and sizes attributes let the browser choose a file that fits the display, instead of downloading the biggest one to everyone.