Performance: Object-fit for images and media
MEDIUM IMPACT
This affects how images and media scale and fit within their containers, impacting layout stability and paint performance.
<img src="photo.jpg" class="w-64 h-64 object-cover" alt="Photo">
<img src="photo.jpg" class="w-64 h-64" style="width:16rem; height:16rem;" alt="Photo">
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Image without object-fit in fixed container | Minimal | Multiple on load if image size differs | High due to repaints from layout shifts | [X] Bad |
| Image with object-fit (e.g., object-cover) | Minimal | Single initial reflow | Lower paint cost due to stable layout | [OK] Good |