odin-lang / odin-lang.org

http://odin-lang.org
26 stars 83 forks source link

fix: dark mode flicker #223

Closed MarkusWendorf closed 3 months ago

MarkusWendorf commented 3 months ago

Because the JS script that handles the dark mode setting (via localStorage) is located after all other content, there's a small window where the page is rendered with default theme settings.

This causes the page to flicker:

https://github.com/odin-lang/odin-lang.org/assets/18446907/85090484-6cdb-406c-9b4a-cebad8885eeb

This PR fixes this behaviour by moving the script up to the first child of the body. I've also moved the toggleDarkMode inside the script, so the dark mode logic is all in one place.