, , Rails Prototype. , JavaScript:
Prototype.preloadImages = function(){
for(var i=0, images=[]; src=arguments[i]; i++){
images.push(new Image());
images.last().src = src;
}
};
Then add this code wherever your download code runs. Maybe something like this:
Event.observe(window, 'load', function(){
Prototype.preloadImages('header/home_over.gif','another/image/to/preload.gif');
});
You must make sure that all magic image_tag()is done for the image paths to ensure that the correct image is preloaded.
source
share