Performance: Why SASS exists
MEDIUM IMPACT
SASS affects the CSS authoring process and indirectly impacts page load by enabling better organized and smaller CSS files.
$primary-color: #3498db; $alert-color: #e74c3c; $padding: 1rem; $radius: 0.5rem; .button { background-color: $primary-color; color: white; padding: $padding; border-radius: $radius; } .alert { background-color: $alert-color; color: white; padding: $padding; border-radius: $radius; }
/* Plain CSS with repeated code and no variables */ .button { background-color: #3498db; color: white; padding: 1rem; border-radius: 0.5rem; } .alert { background-color: #e74c3c; color: white; padding: 1rem; border-radius: 0.5rem; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Plain CSS with repetition | N/A | N/A | Higher due to larger CSS | [X] Bad |
| SASS compiled optimized CSS | N/A | N/A | Lower due to smaller CSS | [OK] Good |