Performance: Design token management
MEDIUM IMPACT
Design token management affects CSS generation and runtime style recalculations, impacting page load speed and rendering consistency.
$colors: ( primary: #007bff, secondary: #6c757d ); @function color($name) { @return map-get($colors, $name); } .button { color: color(primary); background-color: color(secondary); } // Centralized tokens with map and function
$primary-color: #007bff; $secondary-color: #6c757d; $primary-color: #0056b3; // redefining tokens multiple times .button { color: $primary-color; background-color: $secondary-color; } // Tokens scattered and redefined in many files
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Scattered and redefined tokens | No direct DOM impact | Triggers multiple style recalculations | Higher paint cost due to inconsistent styles | [X] Bad |
| Centralized tokens with Sass maps and functions | No direct DOM impact | Single style calculation on load | Lower paint cost with consistent styles | [OK] Good |