Performance: Justify content
LOW IMPACT
Controls horizontal alignment of items in a flex or grid container, affecting layout calculation and paint.
display: flex; justify-content: space-between; /* no manual margins on children */
display: flex; justify-content: space-between; /* then manually adding margins on children */ .child { margin-left: 20px; margin-right: 20px; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using justify-content only | Minimal DOM changes | 1 reflow per layout change | Low paint cost | [OK] Good |
| Justify-content plus manual margins | Extra DOM style changes | Multiple reflows if margins change | Higher paint cost | [X] Bad |