Performance: Defining grid rows
MEDIUM IMPACT
This affects how the browser calculates layout and paints grid rows, impacting rendering speed and visual stability.
<div class="grid grid-cols-3 grid-rows-2"> <div>Item 1</div> <div>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div>
<div class="grid grid-cols-3"> <div>Item 1</div> <div>Item 2</div> <div>Item 3</div> <div>Item 4</div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Grid without defined rows | Standard DOM nodes | Multiple reflows on content/layout changes | Higher paint cost due to layout shifts | [X] Bad |
| Grid with defined rows (e.g., grid-rows-2) | Standard DOM nodes | Single reflow on initial layout | Lower paint cost, stable layout | [OK] Good |