PreloaderJS Demo


This is the demo page for PreloaderJS, a tiny and very simple image preloading library. You can also check your browser console or view the page source for more info about the demo.

For testing purposes, only the files 1.jpg, 2.jpg, 3.jpg and 4.jpg exist, any other image will not be loaded.


Example 1

	        
Preload({
    sources: ['img/1.jpg', 'img/2.jpg', 'img/3.jpg', 'img/4.jpg'],
    onComplete: function () {
        console.log('All files preloaded');
    },
    onSuccess: function () {
    	console.log('All files successfully loaded');
    },
    onError: function () {
    	console.log('Should not be called');
    }
});
        
    



Example 2

	        
Preload({
    sources: ['img/0.jpg', 'img/1.jpg'],
    onComplete: function (result, err) {
    	if (err) {
        	console.log('All files preloaded, some with errors, some successfully');
        } else {
        	console.log('Should not be called');
        }
    },
    onError: function (result) {
        var imagesNotLoadedList = result.notLoaded.join(', ');
        console.log('Files not preloaded: ' + imagesNotLoadedList);

        var imagesLoadedList = result.loaded.join(', ');
        console.log('Files preloaded: ' + imagesLoadedList);
    }
});