Skip to content

Instantly share code, notes, and snippets.

@MilkZoft
Created January 16, 2012 03:48
Show Gist options
  • Select an option

  • Save MilkZoft/1618953 to your computer and use it in GitHub Desktop.

Select an option

Save MilkZoft/1618953 to your computer and use it in GitHub Desktop.
Preloading images
(function($) {
var cache = [];
$.preLoadImages = function() {
var argsLen = arguments.length;
for(var i = argsLen; i--;) {
var cacheImage = document.createElement('img');
cacheImage.src = arguments[i];
cache.push(cacheImage);
}
}
}
jQuery.preLoadImages("img1.gif", "/path/to/img2.png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment