Is the function I wrote below enough to preload images in most, if not all, browsers commonly used today?
JavaScript
x
6
1
function preloadImage(url)
2
{
3
var img=new Image();
4
img.src=url;
5
}
6
I have an array of image URLs that I loop over and call the preloadImage
function for each URL.
Advertisement
Answer
Yes. This should work on all major browsers.