Dharmen Shah
Sr. Full-Stack Developer
Having successfully employed this technique to implement a client-side light/dark theme switching feature, I have one observation that others might find helpful: other than the page load "flash" Johan Fredrik Varen mentioned, the only other issue is that the Darkly theme uses slightly different size metrics to the default Bootstrap theme. So when the theme switches some page components are resized, which makes it appear that more than a light/dark switch has occurred. I have found that switching between Lightly and Darkly avoids any component resizing.
This is a beautiful way of doing it, except for the one major flaw: The flash of light-mode at every page (re)load. I've tried several approaches, but as long as you set the dark-mode stylesheet URL using JS you'll either have a bright flash of unstyled content or a bright flash of light-mode content. This is even visible in the GIF shown in this article. I'm afraid I've no choice but to ditch this approach and resort to backend rendering.
david lafontant
Full-stack web developer
The most elegant solution I ever saw. Thank you very much.