Performance: Functions with parameters
LOW IMPACT
This affects the CSS generation time and the final CSS file size, impacting page load speed.
@function shade-color($color, $percent) { @return mix(black, $color, $percent / 100); } $primary-color: #3498db; .button { background-color: $primary-color; } .alert { background-color: shade-color($primary-color, 20); }
$primary-color: #3498db; .button { background-color: #3498db; } .alert { background-color: #2980b9; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Hardcoded repeated colors | No impact | No impact | No impact | [X] Bad |
| Parameterized functions for colors | No impact | No impact | No impact | [OK] Good |