Per this extremely popular question, preloading images with javascript is as easy as:
function preloadImage(url) {
var img=new Image();
img.src=url;
}
But what I'd like to know is how can you know when that's done? I could just do a small setTimeout and assume it will be done after some small delay, but with varying connection speeds and especially for large images or large numbers of images this is unreliable.
Is there any way to actually know for sure when the loading is done?