Skip to content

Instantly share code, notes, and snippets.

@chriscoyier
Created March 31, 2011 16:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save chriscoyier/896686 to your computer and use it in GitHub Desktop.
Save chriscoyier/896686 to your computer and use it in GitHub Desktop.
var tooFast = false;
$(window).load(function() {
tooFast = true;
});
function bindLoad() {
if (tooFast) {
$("html").addClass("loaded");
} else {
$(window).load(function() {
$("html").addClass("loaded");
});
}
}
setTimeout(bindLoad, 500);
@paulirish
Copy link

(function fn(){

  fn.now = +new Date;

  $(window).load(function f() {
      if (+new Date - fn.now < 500) setTimeout(f, 500);
      $("html").addClass("loaded");
  });

})();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment