Performance: Media-based dark mode strategy
MEDIUM IMPACT
This affects initial page load speed and rendering by conditionally applying styles based on user system preferences.
@media (prefers-color-scheme: dark) { .dark\:bg-gray-900 { background-color: #111; } .dark\:text-gray-200 { color: #eee; } } /* Tailwind applies these automatically */@media (prefers-color-scheme: dark) { body { background-color: #111; color: #eee; } } /* plus JavaScript toggling classes on load */| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| JavaScript toggling dark mode after load | Multiple class changes | Multiple reflows triggered | Multiple paints causing CLS | [X] Bad |
| CSS media query for dark mode | No DOM changes | Single reflow during initial layout | Single paint with no CLS | [OK] Good |