Performance: Avoiding over-nesting
MEDIUM IMPACT
This affects CSS selector matching speed and browser rendering performance by reducing complexity in style calculations.
.parent { color: blue; } .child { color: green; } .grandchild { color: red; }
& .parent { & .child { & .grandchild { color: red; } } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deeply nested selectors | No extra DOM nodes but complex matching | 0 | Higher due to slower style calculation | [X] Bad |
| Flat selectors with minimal nesting | No extra DOM nodes, simple matching | 0 | Lower due to faster style calculation | [OK] Good |