Running number preloader in JavaScript

Recently, I had to implement a preloader for a one-page web application.

With some JSON slurping/parsing and a little regex that reads files that end in png or jpg, I was set.

For this example, I've stripped out the parsing component to demonstrate the preloader itself. To make things a little more theatrical, I've used the excellent animateNumber library.

HTML:

 <h2>Progress:
   <font id="progressLoader">0<font>
 <h2>

JavaScript:

var imagesToLoad = [    "http://upload.wikimedia.org/wikipedia/commons/2/22/Turkish_Van_Cat.jpg",  
    "http://a.dilcdn.com/bl/wp-content/uploads/sites/8/2012/09/02-11.jpg",
    "http://www.zastavki.com/pictures/1680x1050/2010/Animals_Cats_Cat_023761_.jpg",
    "http://www.webmastergrade.com/wp-content/uploads/2009/07/Cat-with-Hat.jpg",
    "http://i.huffpost.com/gen/1860407/thumbs/o-BLACK-FOOTED-CAT-KITTENS-facebook.jpg"]

    function preloadImages(imagesToLoad) {
        var loadFrom = 0;
        var loaded_images = 0;
        for (var i = 0; i < imagesToLoad.length; i++) {
            //Create and hide elements in DOM for display/caching
            var img = document.createElement(\'img\');
            img.src = imagesToLoad[i];
            img.style.display = \'none\';
            img.onload = function () {
                loaded_images++;
                if (loaded_images == imagesToLoad.length) {
                    document.getElementById("progressLoader").innerHTML = "100";
                    setTimeout(function () {
                        alert("Success!");
                    }, 2000); //wait two seconds, and celebrate
                }
                if (loadFrom == "" || loadFrom == null) loadFrom = 0;
                currentLoad = Math.round(100 * loaded_images / imagesToLoad.length);
                $(\'#progressLoader\')
                    .prop(\'number\', loadFrom)
                    .animateNumber({
                    number: currentLoad
                });
                loadFrom = currentLoad;
            };
            document.body.appendChild(img);
        }
    }

preloadImages(imagesToLoad);  

For a demo, try the jsfiddle.