selfdefined / web-app

Dictionary database with future API and bot integrations
https://www.selfdefined.app/
572 stars 172 forks source link

fix: Prevent flash of light mode if dark mode is selected #446

Closed eps1lon closed 2 years ago

eps1lon commented 2 years ago

Instead of initializing the theme in a deferred script we now initialize it before any html is parsed. This prevents a flash of light mode when light mode is selected between the page being rendered and JS being executed.

tatianamac commented 2 years ago

Congrats and thank you for your first PR, @eps1lon ! Appreciate you looking out for this sort of thing.

I want to provide a bit of context around why we deferred initially: Rather than load the script unnecessarily for all, we wanted to only load as needed (which trade off, as you identified, is flash).

I am going to ask a few folks with more niche performance knowledge in this to provide more prescriptive feedback to your PR, including @malchata ! stay tuned for feedback. Thank you!

ovlb commented 2 years ago

Also fine with this. Is there an acronym for flash of unstyled light mode already?

🦭 of aprroval