Skip to content

Instantly share code, notes, and snippets.

@pierre-b
Created December 19, 2014 23:02
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
Javascript image preload
var preloadImage = function(src, callback){
var img = new Image();
img.src=src;
img.onload = function(){
callback();
}
};
// usage
preloadImage(path, function(){
console.log('image loaded, do more stuff here');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment