Performance: Responsive images
HIGH IMPACT
Responsive images affect page load speed by delivering appropriately sized images for different screen sizes, reducing data usage and improving rendering time.
<img srcset="small.jpg 480w, medium.jpg 800w, large.jpg 1200w" sizes="(max-width: 600px) 480px, (max-width: 900px) 800px, 1200px" src="large-image.jpg" alt="Example image">
<img src="large-image.jpg" alt="Example image">
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Single large image for all devices | Minimal | 1 reflow on load | High paint cost due to large decode | [X] Bad |
| Responsive images with srcset and sizes | Minimal | 1 reflow on load | Lower paint cost due to smaller images | [OK] Good |