Preload a set of images with jQuery

    [javascript]
    function preload(arrayOfImages) {
    $(arrayOfImages).each(function(){
    $(‘<img/>’)[0].src = this;
    // Alternatively you could use:
    // (new Image()).src = this;
    });
    }

    // Usage:

    preload([
    ‘img/imageName.jpg’,
    ‘img/anotherOne.jpg’,
    ‘img/blahblahblah.jpg’
    ]);
    [/javascript]

    Tags:

    Leave a Reply