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.
Johan Fredrik Varen
Backend dev