Performance: Ratio utilities for embeds
MEDIUM IMPACT
This affects the page's layout stability and loading speed by controlling the aspect ratio of embedded content without extra scripts.
<div class="ratio ratio-16x9"> <iframe src="https://www.youtube.com/embed/zpOULjyy-n8" title="Video embed" allowfullscreen></iframe> </div>
<iframe src="https://www.youtube.com/embed/zpOULjyy-n8" style="width:100%; height:auto;"></iframe>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Iframe without ratio container | Minimal DOM nodes | Multiple reflows on load | Higher paint cost due to layout shifts | [X] Bad |
| Iframe inside Bootstrap ratio utility | One extra div node | Single reflow with reserved space | Lower paint cost, stable layout | [OK] Good |