Performance: Chained extensions
MEDIUM IMPACT
Chained extensions affect CSS compilation time and the final CSS size, impacting page load speed and rendering performance.
%base-style { font-size: 1rem; margin: 1rem; padding: 1rem; }
.button { @extend %base-style; background: blue; color: black; }@mixin base { color: black; } %base-style { font-size: 1rem; } %extended-style { @extend %base-style; margin: 1rem; } %final-style { @extend %extended-style; padding: 1rem; } .button { @extend %final-style; background: blue; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Long chained @extend selectors | No direct DOM changes | Triggers multiple style recalculations | Higher paint cost due to complex styles | [X] Bad |
| Single-level @extend with consolidated styles | No direct DOM changes | Minimal style recalculations | Lower paint cost with simpler styles | [OK] Good |