Performance: Mixin definition with @mixin
MEDIUM IMPACT
This affects CSS generation size and browser rendering by reusing style blocks efficiently.
@mixin blue-box { background-color: blue; border-radius: 0.5rem; padding: 1rem; } button { @include blue-box; } .card { @include blue-box; }
button {
background-color: blue;
border-radius: 0.5rem;
padding: 1rem;
}
.card {
background-color: blue;
border-radius: 0.5rem;
padding: 1rem;
}| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated styles without mixin | No change | No change | Higher due to larger CSS | [X] Bad |
| Styles reused with @mixin | No change | No change | Lower due to smaller CSS | [OK] Good |