How to Make the Perfect Dark Mode Switcher
Websites should match users' system settings for the best experience. One important setting is the system theme, which can be dark or light. Here's how to do that in the best way.
1. The Basics: prefers-color-scheme Media Query
Browsers now support ...
webartisan.info6 min read
Max
This is a great approach. It's the only one I've tried that's actually worked. I just wanted to add one thing. For mobile bf cache, I added a pageshow event listener to the deferred section of script so that the preference would persist. Without it, it wasn't — at least on Android Chrome and Firefox. Thanks again for the awesome tutorial!