Performance: Flex direction control
MEDIUM IMPACT
Controls how flex items are laid out, affecting layout calculation and paint performance.
<div id="container" class="flex flex-col">...</div> <script> const container = document.getElementById('container'); container.classList.replace('flex-col', 'flex-row'); </script>
<div class="flex flex-col">...</div> <script> document.querySelectorAll('.flex').forEach(el => { el.classList.remove('flex-col'); el.classList.add('flex-row'); }); </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Changing flex direction on many elements individually | Many class changes | N reflows for N elements | High paint cost | [X] Bad |
| Changing flex direction on a single container | One class change | Single reflow | Low paint cost | [OK] Good |