Javascript image preload

Javascript image preload


How to get rid of the delay that happens when you use multiple images with 'onmouseover'? Preload all the images.

You can supply one image url as an argument to this function, or an array of image urls.

Source code for imagepreload.js

function ImagePreload() {
	if (typeof(arguments) != 'undefined') {
		for (i=0; i<arguments.length; i++ ) {
			if (typeof(arguments[i]) == "object") {
				for (k=0; k<arguments[i].length; k++) {
					var oImage = new Image;
					oImage.src = arguments[i][k];
				}
			}
 
			if (typeof(arguments[i]) == "string") {
				var oImage = new Image;
				oImage.src = arguments[i];
			}
		}
	}
}