Performance: Object fit
MEDIUM IMPACT
Controls how replaced elements like images or videos fit within their container, impacting layout and paint performance.
img { width: 100%; height: 100%; object-fit: cover; }img { width: 100%; height: auto; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using width:auto and height:auto without object-fit | Low | Multiple reflows on image load | High due to layout shifts | [X] Bad |
| Using fixed container with object-fit: cover | Low | Single reflow | Low paint cost | [OK] Good |