Performance: @each loop over lists
MEDIUM IMPACT
This affects CSS generation time and the final CSS file size, impacting page load speed and rendering.
@each $color in (red, blue, green) { .btn-#{$color} { background-color: $color; } } /* Use CSS variables or utility classes for other colors to reduce duplication */
@each $color in (red, blue, green, yellow, orange, purple, pink, brown, black, white) { .btn-#{$color} { background-color: $color; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large @each loop generating many classes | 0 (compile time only) | 0 | High due to large CSS | [X] Bad |
| Small @each loop with few classes | 0 (compile time only) | 0 | Low CSS size, faster paint | [OK] Good |