Performance: Variable scope (global vs local)
MEDIUM IMPACT
Variable scope affects how and when styles are compiled, impacting CSS output size and compilation speed.
$color: red; .button { color: $color; } .card { $local-color: blue; color: $local-color; }
$color: red; .button { color: $color; } .card { $color: blue; color: $color; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Global variable overuse | No direct DOM impact | No reflows | Larger CSS can slow paint | [X] Bad |
| Local variable usage | No direct DOM impact | No reflows | Smaller CSS speeds paint | [OK] Good |