Performance: Offset class generation
MEDIUM IMPACT
This affects CSS file size and browser style calculation speed, impacting page load and rendering performance.
.offset { margin-left: var(--offset, 0); } // Use inline style or CSS variables to set offset dynamically without generating many classes
@for $i from 1 through 12 { .offset-#{$i} { margin-left: percentage($i / 12); } } // Generates 12 separate classes with fixed margin-left values
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Many generated offset classes | Low (CSS only) | Multiple reflows if classes toggle | Moderate due to style recalculation | [X] Bad |
| Single offset class with CSS variable | Low (CSS only) | Single reflow on variable change | Low paint cost | [OK] Good |