/browser-image-preloader

A simple tool for preloading images in the browser.

Primary LanguageJavaScript

browser-image-preloader

install

Add script to your document:

<script type="text/javascript" src="browser-image-preloader/index.js"></script>

usage

Preload images:

browserImagePreloader('path/to/image1.png', 'path/to/image2.png', 'path/to/image3.png').load();

Add handlers:

browserImagePreloader('path/to/image1.png', 'path/to/image2.png', 'path/to/image3.png')
.loaded( function (img, percent) {
  console.log(img.src, 'loaded at', percent);
})
.done( function () {
  console.log('finished loading images');
}).load();

notes

We can treat browser-image-preloader as a CommonJS module if using something like Browserify:

var preloader = require('browser-image-preloader');