Performance: Accessibility utility generation
MEDIUM IMPACT
This affects page load speed and rendering by adding CSS utilities that improve accessibility without bloating the stylesheet.
%sr-only {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
border: 0;
}
.sr-only {
@extend %sr-only;
}
.element {
@extend .sr-only;
}@mixin sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); border: 0; } .element { @include sr-only; @include sr-only; @include sr-only; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Repeated mixin includes for accessibility utilities | No extra DOM nodes | Multiple reflows if styles change | Higher paint cost due to redundant styles | [X] Bad |
| Sass placeholder selectors with @extend for utilities | No extra DOM nodes | Single reflow on style change | Lower paint cost with shared styles | [OK] Good |