Performance: Future CSS features replacing SASS
This affects page load speed by reducing CSS preprocessing time and bundle size, improving rendering speed.
Jump into concepts and practice - no test required
:root {
--primary-color: #3498db;
}
.button {
color: var(--primary-color);
}
.button .icon {
margin-right: 0.5rem;
}$primary-color: #3498db; .button { color: $primary-color; .icon { margin-right: 0.5rem; } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| SASS nested selectors | No change | No change | Higher due to larger CSS | [X] Bad |
| Native CSS variables and flat selectors | No change | No change | Lower due to smaller CSS | [OK] Good |
--name: value; inside selectors.& nesting selector to nest selectors, e.g., nav { & ul { list-style: none; } }.nav { ul { ... } }, but future CSS requires & or pseudo-classes like :is() or :where().<div> in this CSS using future CSS variables?:root { --main-color: coral; } div { background-color: var(--main-color); }--main-color is set to coral in the :root selector, making it global.div uses background-color: var(--main-color); which fetches the value coral.section { article { padding: 1rem; } }:is() or :where(). Plain article is invalid.section { & article { padding: 1rem; } } or using pseudo-classes.screen and (min-width: 600px).1.2rem is better for accessibility and scaling than fixed pixels.