Skip to content

Instantly share code, notes, and snippets.

@name-k
Created September 28, 2013 14:41
Show Gist options
  • Save name-k/6742754 to your computer and use it in GitHub Desktop.
Save name-k/6742754 to your computer and use it in GitHub Desktop.
$(function() {
// To keep track of how many images have loaded
var loaded = 0;
// Let's retrieve how many images there are
var numImages = $("img").length;
// Let's bind a function to the loading of EACH image
$("img").load(function() {
// One more image has loaded
++loaded;
// Only if ALL the images have loaded
if (loaded === numImages) {
// This will be executed ONCE after all images are loaded.
// YOUR CODE GOES HERE function() { ... }
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment