Created
March 28, 2012 16:59
-
-
Save namklabs/2228214 to your computer and use it in GitHub Desktop.
Prevent FOUC on an element or the whole body with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//From http://www.robertmullaney.com/2011/08/29/prevent-flash-of-unstyled-content-fouc-jquery/ | |
//I have a project which uses jQuery UI for tables (formatting), buttons, tabs, etc. Even though my local resources and remotely hosted ones are saved in the browser’s cache, I still have situations where a FOUC (Flash of Unstyled Content) occurs. | |
//Here is a simple solution… | |
$(function() { | |
$('body').hide(); | |
$(window).load(function(){ | |
$('body').show(); | |
}); | |
}); | |
//Adjust the body selector to your needs of course ;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment