Performance: Layer organization (base, components, utilities)
MEDIUM IMPACT
This affects how quickly styles are applied and how efficiently the browser processes CSS during page load and rendering.
@layer base { body { margin: 0; } } @layer components { .card { @apply shadow-lg p-6; } .btn { @apply px-4 py-2 bg-blue-500; } } @layer utilities { .text-shadow { text-shadow: 1px 1px 2px black; } }@layer utilities { .btn { @apply px-4 py-2 bg-blue-500; } } @layer base { body { margin: 0; } } @layer components { .card { @apply shadow-lg p-6; } }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Mixed layer order | N/A | Multiple style recalculations | Higher paint cost due to unstable styles | [X] Bad |
| Ordered layers: base, components, utilities | N/A | Single style recalculation | Lower paint cost with stable styles | [OK] Good |