background image preload

Posted by Bharanikumar on Stack Overflow See other posts from Stack Overflow or by Bharanikumar
Published on 2010-06-02T07:29:31Z Indexed on 2010/06/02 7:33 UTC
Read the original article Hit count: 295

Shall i use below snippet for preload background images,

or else is there any snippet there ,

function preload(images) {
if (document.images) {
    var i = 0;
    var imageArray = new Array();
    imageArray = images.split(',');
    var imageObj = new Image();
    for(i=0; i<=imageArray.length-1; i++) {
        //document.write('<img src="' + imageArray[i] + '" />');// Write to page (uncomment to check images)
        imageObj.src=images[i];
    }
} }

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery