Posted: December 16, 2009 at 8:11 AM by jbuda
Tags: jQuery
Was looking for a way to preload images and display some sort of loader. This small snippet is the functionality to do, the onload callback enables extra functions to be run on image once it is complete.
var img = new Image();
img.src = imgURL;
img.id = ''new_image'';
$(img).load(function() {
//once image loaded, add it into div with imageholder id
$("#imageholder").append(img);
});

twitpic photos