RatanShreshtha / DeepThought

A simple blog theme focused on writing powered by Bulma and Zola.
https://deepthought-theme.netlify.app/
MIT License
176 stars 92 forks source link

Dark mode flickers on load of new page #46

Open JulianWgs opened 2 years ago

JulianWgs commented 2 years ago

After activating the dark mode and clicking on any link inside the website the light theme quickly flickers before the page is set to the dark theme again.

An example would be when clicking on the on the posts page from the home page.

Affected browsers: Firefox 94.0 (64-bit) on Ubuntu 20.04.3 LTS Chrome Version 95.0.4638.69 (Official Build) (64-bit) on Ubuntu 20.04.3 LTS iOS 14.8.1

According to StackOverflow this solution is to have a blocking change of theme before the page loads: https://stackoverflow.com/a/63033934

But it seams the theme is changed after the page is ready, hence the flicker: https://github.com/RatanShreshtha/DeepThought/blob/3596d4c1b975dfadd94efc150de10f5c7232eb6d/static/js/site.js#L171-L176