• With dark theme enabled in the 2021 theme, it looks like after CSS is optimized (I turned off all others), the css is loaded again, so the page first appear in non-dark mode and then applied to dark more?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter hz_i3

    (@hz_i3)

    Maybe due to this? The dark theme CSS is treated non-critical CSS?

    “Phast loads non-critical CSS asynchronously and in a single request.”

    Plugin Author Albert Peschar

    (@kiboit)

    Hi @hz_i3,

    The theme uses JavaScript to detect dark mode, even though it can be done with CSS only. PhastPress delays JavaScript execution, so the pre-JavaScript version is rendered for a short while.

    The JavaScript adds a “is-dark-theme” class to the page. But the CSS rules for this class are optimized away because the class is not present in the document before the JavaScript is executed.

    That’s why there’s a short flash before the full CSS is loaded and JS is executed.

    I’ve now released version 1.121 of PhastPress which adds a work-around for the dark mode functionality in the theme. It ensures that the JavaScript is executed immediately, and that the CSS rules are not optimized away.

    After updating to this new version you should no longer experience this problem.

    –Albert

    Thread Starter hz_i3

    (@hz_i3)

    It doesn’t work for some pages… It might be that the dark theme JS is executed too late, after all the inlined CSS?

    Plugin Author Albert Peschar

    (@kiboit)

    Hi @hz_i3,

    You did update to the latest version (1.121), right?

    Would you be able to share the URL of your site with me, so that I can have a look? If you don’t want to post it publicly, you can use the contact details at the bottom of the plugin description.

    –Albert

    Plugin Author Albert Peschar

    (@kiboit)

    PS: If you are using a caching plugin, make sure that the cache has been empty after updating to make sure that the pages are optimized again.

    Thread Starter hz_i3

    (@hz_i3)

    Hi Albert. I just emailed you.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Page flashes for 2021 dark theme’ is closed to new replies.