Performance: sass:map module
MEDIUM IMPACT
Using the sass:map module affects the CSS compilation speed and the size of the generated CSS, impacting initial page load speed.
$colors: (primary: #ff0000, secondary: #00ff00, accent: #0000ff); .button { color: map.get($colors, primary); } .alert { color: map.get($colors, secondary); } .link { color: map.get($colors, accent); }
$colors-primary: #ff0000; $colors-secondary: #00ff00; $colors-accent: #0000ff; .button { color: $colors-primary; } .alert { color: $colors-secondary; } .link { color: $colors-accent; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Separate variables for related values | N/A | N/A | Higher due to larger CSS | [X] Bad |
| Using sass:map module for related values | N/A | N/A | Lower due to smaller CSS | [OK] Good |