Performance: Extending vs mixing comparison
MEDIUM IMPACT
This affects CSS file size and browser rendering speed by changing how styles are reused and combined.
%button-style {
padding: 1rem 2rem;
border-radius: 0.5rem;
background-color: blue;
color: white;
}
.primary-button {
@extend %button-style;
}
.secondary-button {
@extend %button-style;
background-color: gray;
}@mixin button-style { padding: 1rem 2rem; border-radius: 0.5rem; background-color: blue; color: white; } .primary-button { @include button-style; } .secondary-button { @include button-style; background-color: gray; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| @mixin reuse | No change | No change | Higher due to larger CSS | [!] OK |
| @extend reuse | No change | No change | Lower due to smaller CSS | [OK] Good |