-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Flash of wrong styles #20
Comments
The problem really is that you’re actively “fighting” the browser. The browser is like “oh, the user prefers dark, so I better adapt and turn the body background and other UI elements dark, too”, but then, via the toggle, you override the preference, so there’s this flash of white. Even when you So long story short, there’s no way to prevent this, but you can limit the negative effect by making sure the toggle code executes as soon as possible during the loading phase of your page. Hope this helps somewhat. |
thanks for your answer! |
Great project overall, its a nice inspiration!
All solutions I discovered on the web with a permenent switch and also my own custom code suffer from a flash of the wrong styles at some point before the styles accoring to localStorage setting is applied. This happens in latest Chrome, but not in Desktop and Mobile Safari.
your regular demo does (on page reload) and v8.dev also, only your barebones demo seems fast enough
is it just not possible to avoid a flash (e.g. white background flash before dark background gets applied) without blocking the rendering or hiding the page or do have a suggestion?
The text was updated successfully, but these errors were encountered: