Performance: Mixin libraries pattern
MEDIUM IMPACT
This pattern affects CSS bundle size and rendering speed by how styles are generated and reused.
.button { padding: 1rem 2rem; border-radius: 0.5rem; background-color: blue; color: white; } .button1, .button2, .button3 { @extend .button; }
@mixin button-style { padding: 1rem 2rem; border-radius: 0.5rem; background-color: blue; color: white; } .button1 { @include button-style; } .button2 { @include button-style; } .button3 { @include button-style; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Mixin included multiple times | No extra DOM nodes | No extra reflows | Higher paint cost due to larger CSS | [X] Bad |
| Shared class with @extend | No extra DOM nodes | No extra reflows | Lower paint cost due to smaller CSS | [OK] Good |