Performance: Pairing light and dark colors
MEDIUM IMPACT
This affects the rendering speed and visual stability of pages when switching between light and dark modes.
<div class="bg-white text-black dark:bg-black dark:text-white">...</div><div class="bg-white text-black" id="theme-container">...</div> <script> const darkMode = true; // or false document.body.style.backgroundColor = darkMode ? '#000000' : '#ffffff'; document.body.style.color = darkMode ? '#ffffff' : '#000000'; </script>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| JavaScript style changes on theme toggle | Multiple style changes on body element | Multiple reflows per toggle | High paint cost due to forced repaints | [X] Bad |
| Tailwind dark mode classes | No extra DOM operations | No reflows on toggle | Single paint with GPU acceleration | [OK] Good |