Skip to content

Instantly share code, notes, and snippets.

@namklabs
Created March 28, 2012 16:59
Show Gist options
  • Save namklabs/2228214 to your computer and use it in GitHub Desktop.
Save namklabs/2228214 to your computer and use it in GitHub Desktop.
Prevent FOUC on an element or the whole body with jQuery
//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