Performance: Mix function for blending
MEDIUM IMPACT
This affects the CSS generation size and the browser's paint performance when blending colors dynamically.
$primary: #ff0000; $secondary: #0000ff; $blend-50: mix($primary, $secondary, 50%); .background { background-color: $blend-50; } // Reuse $blend-50 variable instead of recalculating
$color1: #ff0000; $color2: #0000ff; .background { background-color: mix($color1, $color2, 50%); } // Repeated many times with different percentages
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Many unique mix() calls | 0 (CSS only) | 0 | High paint cost due to many unique colors | [X] Bad |
| Precomputed mix() variables reused | 0 (CSS only) | 0 | Lower paint cost with fewer unique colors | [OK] Good |