Performance: Mixins with parameters
MEDIUM IMPACT
This affects CSS generation size and browser rendering speed by controlling how styles are reused and customized.
@mixin button-style($bg-color) { padding: 1rem 2rem; border-radius: 0.5rem; background-color: $bg-color; color: white; } .button-primary { @include button-style(blue); } .button-secondary { @include button-style(gray); }
@mixin button-style { padding: 1rem 2rem; border-radius: 0.5rem; background-color: blue; color: white; } .button-primary { @include button-style; } .button-secondary { @include button-style; background-color: gray; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Non-parameterized mixins with many variations | N/A | N/A | Higher due to larger CSS | [X] Bad |
| Parameterized mixins reusing styles efficiently | N/A | N/A | Lower due to smaller CSS | [OK] Good |