views:

49

answers:

2

Hello!

Can you tell me if the function I wrote below is enough to preload images in most if not all browsers commonly used today?

function preloadImage(url)
{
    var img=new Image();
    img.src=url;
}

I have an array of imageURLs that I loop and call the preloadImage function for each URL.

Thank you.

+2  A: 

yes.. this should work on all major browsers

Huzi--- Javiator
Thank you Huzi.
Francisc
+2  A: 

Alternatives: http://www.thecssninja.com/css/even-better-image-preloading-with-css2

mplungjan
Thanks mplungjan. Although it doesn't help me with this particular case, it is good to know.
Francisc