-
Notifications
You must be signed in to change notification settings - Fork 343
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
Flashing when switching between pages in dark theme. #1325
Comments
This is a great suggestion and something that I've already put some time into trying to improving. Since the dark/light styling is generated entirely using CSS, it is challenging to avoid this! I will investigate the Hugo solution and do my best to get this fixed sometime soon. |
I have noticed the same issue with Quarto 1.1.251 and Chrome 105. No flashing though with Firefox 104. It seems the page is nearly fully rendered first with the light theme and only then switched to the dark theme by the
Two solutions suggested on SO:
|
Thanks for the suggestions - I will tinker a bit more and see if either remove or reduce the FOUC.. |
Because we implement our themes based upon toggling linked stylesheets (e.g. toggling the alternate/dark on or off on top of the existing light style), there is at least some latency introduced by the stylesheet fetch. I tinkered a bit with trying to be very optimal in how we process these stylesheets, including trying to reorder the link tags very early in the load process, but in each case the flash remained (and in many cases was unfortunately worse). I think the solution maybe to consolidate the generated theme CSS into a single stylesheet with appropriate dark/light selectors at the root level. This is larger task and so I'm leaving this open for 1.3 to track. |
Any news on this? |
No update yet- this is something that I'd like to get to but am still working through other priorities. |
Yeah, users don't like this flashing. If the new Bootswatch paired light/dark mode is implemented correctly #6741, can this improve the situation? The https://getbootstrap.com/ page itself has no flashing. |
I tried all the same kinds of things that @dragonstyle mentions, just mucking about in the html output. Nothing helped. Then I saw that the dark stylesheet is Actually tbh I had given up and said "I do not know what Then I read about prefetching, and I think we don't want the dark stylesheets to load in the background, because we may need them immediately. Have not found where this HTML is generated yet. |
This?
And
|
Thanks @mcanouil! Yes it seems to be the latter. We will still need to set It looks like it was added in 92e0b15 in an attempt to eliminate the FOUC, and we enable or disable the stylesheets using I think what is going on is that stylesheet.rel = 'disable-stylesheet'; almost works, but now we have a (perceptually much quicker) flash of black in light mode from removing the Which then can be eliminated by moving the script to the top of the body instead of the bottom. This also fixes the flash of white plots in dark mode, and is the recommendation of this well-regarded answer on SO. I didn't see any issues, but if there are reasons that parts of the JS need to run after the content is loaded, or if this is a performance concern, we can split the JS into two scripts |
fixes #1325 introduces a new script before the body which runs immediately, enabling/disabling stylesheets and setting body.quarto-light or body.quarto-dark
fixes #1325 introduces a new script before the body which runs immediately, enabling or disabling dark mode TODO: needs to degrade properly when JS is disabled
When you define two themes, one light and one dark. It shows a button for switching light and dark, which is very good.
However, if you choose the dark mode and switch between different pages, chapters or sections. The website is flashing to the light mode first and change to dark theme. It is obvious and easily noticed.
I don't know the reason, but Hugo website do not have this issue. Quarto is great and I really like it, hope it better. Thanks.
The text was updated successfully, but these errors were encountered: