Pre-loading images (and in some cases HTML files) speeds up their display by using your browser’s cache. This means quick loading when the files are required.
var preloadImages = function ()
{
for( var i = 0; i < arguments.length; i++ )
{
this[ i ] = new Image();
this[ i ].src = arguments[ i ];
}
return this;
}
document.body.onload = function()
{
preloadImages(‘path2Image’, ‘path2NextImage’);
}
{
for( var i = 0; i < arguments.length; i++ )
{
this[ i ] = new Image();
this[ i ].src = arguments[ i ];
}
return this;
}
document.body.onload = function()
{
preloadImages(‘path2Image’, ‘path2NextImage’);
}