How to I preload images where it actually forces the images to load before continuing (html/javascri

Posted by Mr. Flibble on Stack Overflow See other posts from Stack Overflow or by Mr. Flibble
Published on 2010-05-21T16:21:32Z Indexed on 2010/05/21 16:50 UTC
Read the original article Hit count: 184

Filed under:
|
|

I want to preload images but ensure they are loaded before continuing. How can I do this?

The following does not work as it sends off the load request only, but doesn't wait till the image is loaded. So it is possible that the image isn't loaded when requested soon after.

jQuery.preloadImages = function () {
        for (var i = 0; i < arguments.length; i++) {
            jQuery("<img>").attr("src", arguments[i]);
        }
    }       
    $.preloadImages("img1.jpg","img2.jpg");

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery