Performance: Why architecture matters at scale
This affects how quickly styles load and apply on large projects, impacting page load speed and smooth rendering.
Jump into concepts and practice - no test required
// 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 |
$base-color: #333;
.button {
color: $base-color;
&:hover {
color: lighten($base-color, 20%);
}
}$font-size: 16px
body {
font-size: $font-size;
}