Search code examples
javascriptjquerypreloadmouse-cursor

Pre-Load Custom Cursors With Javascript


I have been able to successfully preload image gallery before page loads but was wondering how I could do the same for custom cursor.cur files as it doesn't work using the image method below as it cant understand .cur extension?

// Image Preloader
var pictures [
    "a.jpg",
    ..
    "z.jpg"
];

for (var i=0;i < pictures.length; i++){
    var img = new Image()
    img.src = pictures[i];
    img.onload = function(){
        updateProgress();
    }
}

Solution

  • Load the ico file using an AJAX .get() and ignore the response. The response should be cached in the browser. Something like:

        $.get('/favicon.ico', function() {
            alert('Loading of ICO file completed!');
            // Do other processing here
        });  
    

    http://jsfiddle.net/BGG2m/