Performance: Aspect ratio
MEDIUM IMPACT
Aspect ratio affects layout stability and rendering speed by controlling element dimensions before content loads.
img { width: 100%; aspect-ratio: 16 / 9; }img { width: 100%; height: auto; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No aspect-ratio on images | Multiple reflows as images load | Multiple reflows | Higher paint cost due to shifting | [X] Bad |
| Using aspect-ratio property | Single layout calculation | Single reflow | Lower paint cost, stable layout | [OK] Good |