DEV Community 👩‍💻👨‍💻

Discussion on: Detecting dark mode on every request 🌓

mangor1no profile image
Mangor1no

Developers nowadays are running wild while talking about "best pratice" and "anti-pattern" makes me reconsider my basic HTML skill everyday. To summarize, there is no such thing that exists. Everything comes with their own advantages/disadvantages, why do we bother to make things become more complicated, just add a simple tag at the begin of the body and it will be loaded before the whole thing. How slow it could be to load this tiny script? Maybe 0.0001 second or even less?

document.documentElement.classList.add('dark');

Thread Thread
darkwiiplayer profile image
𒊩Wii 💖💛💚💙💜💝💟

Yep. If you want to be really fancy, you can even use that script to set up some simple loading spinner so the page loads more nicely. All in all you'd end up with maybe 10 lines or so.