Performance: Function definition with @function
LOW IMPACT
This affects the CSS compilation time and the final CSS file size, impacting page load speed.
@function color-shade($color, $percent) { @return lighten($color, $percent); } .element1 { color: color-shade(#333, 20%); } .element2 { color: color-shade(#333, 20%); }
@mixin color-shade($color, $percent) { color: lighten($color, $percent); } .element1 { @include color-shade(#333, 20%); } .element2 { @include color-shade(#333, 20%); }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using @mixin for repeated styles | No direct DOM impact | No reflows | Larger CSS causes slower paint | [X] Bad |
| Using @function to return values | No direct DOM impact | No reflows | Smaller CSS improves paint speed | [OK] Good |