Performance: BEM naming with SASS nesting
MEDIUM IMPACT
This affects CSS parsing and rendering speed by influencing selector complexity and style recalculation.
.block { &__element--modifier { color: red; } } // Flattened nesting with combined BEM class
.block { &__element { &--modifier { color: red; } } } // Deep nesting with many levels
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deep nested BEM selectors | No extra DOM nodes | Multiple reflows if styles change | Higher paint cost due to complex styles | [X] Bad |
| Flat BEM combined classes | No extra DOM nodes | Single reflow on style change | Lower paint cost with simpler styles | [OK] Good |