Skip to content
Advertisement

Reloading stylesheet is fluid in Chrome, but weird in Firefox (jQuery)

I am using the following code to reload a stylesheet when the user makes a selection:

JavaScript

In Chrome, the reload happens fluidly, and the transitions look great. In Firefox, the website temporarily becomes a garbled mess (while the stylesheet is being reloaded) for a second before the new stylesheet is active.

Is this something that can be solved with code, or is this just a feature of the Firefox browser?

Advertisement

Answer

If you load the new stylesheet and remove the old one once the new takes effect, the flash of unstyled format should no longer happen

Note: I’ve done away with jquery inside the .ready since I don’t really know how to do a lot of what is happening here in jQuery – vanilla JS all the way for me (but you can convert to jquery if you’re more comfortable with it)

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement