Performance: Grid system mixin from scratch
MEDIUM IMPACT
This affects page load speed and rendering performance by controlling how CSS grid layouts are generated and applied.
@mixin grid-good($columns) { display: grid; grid-template-columns: repeat(#{$columns}, 1fr); }
@mixin grid-bad($columns) { display: grid; grid-template-columns: repeat(#{$columns}, 1fr); > * { width: calc(100% / #{$columns}); } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual width calc in mixin | N/A | Multiple reflows per child | Higher paint cost due to layout thrashing | [X] Bad |
| Pure CSS grid properties | N/A | Single reflow | Lower paint cost, optimized by browser | [OK] Good |