Performance: Minimizing nesting depth
MEDIUM IMPACT
This affects CSS parsing speed, style calculation, and rendering performance by reducing selector complexity and browser workload.
.parent { color: red; } .child { color: red; } .grandchild { color: red; }
.parent { .child { .grandchild { color: red; } } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Deeply nested Sass selectors | No extra DOM nodes but complex selectors | Triggers multiple reflows if styles change | Higher paint cost due to slower style matching | [X] Bad |
| Flat Sass selectors with minimal nesting | No extra DOM nodes, simple selectors | Single reflow on style change | Lower paint cost with faster style matching | [OK] Good |