Performance: Why architecture matters at scale
HIGH IMPACT
This affects how quickly styles load and apply on large projects, impacting page load speed and smooth rendering.
// Define variables and mixins once $primary-color: #333; @mixin base-text { color: $primary-color; font-size: 16px; } .button { @include base-text; } .card { @include base-text; } .alert { @include base-text; } // Styles are modular and reusable
$primary-color: #333; .button { color: $primary-color; font-size: 16px; } .card { color: $primary-color; font-size: 16px; } .alert { color: $primary-color; font-size: 16px; } // Repeated styles everywhere without structure
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated styles without structure | Low | Multiple reflows due to style recalculations | High paint cost from large CSS | [X] Bad |
| Modular styles with mixins and variables | Low | Single reflow for shared styles | Lower paint cost due to smaller CSS | [OK] Good |