#Preventing white flash

1 messages · Page 1 of 1 (latest)

muted tendon
#

Hi all,

Has anyone figured building a theme switcher within their Inertia app, and been able to overcome the "white flash" on page load?

I have a theme switcher myself but the white flash is pretty blinding.

queen arrow
#

I think you're referring to a FOUC, which is quite difficult to overcome. If the user has set their OS theme to light a webpage will by default be white, which will cause a flash. There's not much to do there, apart from setting the theme as fast as possible, which probably means not setting it when the Vue app mounts, but earlier

vapid dew
#

which probably means not setting it when the Vue app mounts, but earlier
Exactly this - the approach I use usually is to keep the selected theme in the localStorage, and add a blocking script in the Blade template directly to apply a class on body depending on the user preferences