Performance: Default parameter values
LOW IMPACT
This affects CSS compilation time and the final CSS bundle size, impacting page load speed.
@mixin button($color: black) { background-color: $color; } .button-primary { @include button(red); } .button-secondary { @include button(blue); } .button-default { @include button(); }
@mixin button($color) { background-color: $color; } .button-primary { @include button(red); } .button-secondary { @include button(blue); } .button-default { @include button(black); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| No default parameters, repeated mixin calls with arguments | N/A | N/A | Larger CSS causes slower style calculation | [X] Bad |
| Default parameters used to avoid repetition | N/A | N/A | Smaller CSS improves style calculation speed | [OK] Good |