DEV Community

Discussion on: The Best Way To Dark Mode Your Website In My Opinion.

Collapse
 
eaich profile image
Eddie • Edited

Ben is mostly correct. The page has to first "disconnect" the current CSS file and then load the second. This will cause a temporary moment when the page doesn't have a CSS file bound to it at all. It will be unnoticeable if the CSS files are small or if all CSS files have been cached locally, but you'll definitely see it if your CSS file is large, if you have multiple CSS files, or if your user's have higher latency.

There may be ways around this including possibly preloading the dark mode CSS.

Collapse
 
zxcodes profile image
Mohammed Farmaan.

Yes that is true. For larger files, it'll take a while to fully load the other sheet but there might be a work around. As soon as I figure it out, I'll pen that one too. Btw, thanks for the point!