preloadimg
A library for preload images
Install
npm install --save preloadimg
Usage
Use in script tag
<script src="src/preloadimg.js" charset="utf-8"></script>
<script>
var imgs = [
'img/image1.png',
'img/image2.png',
'img/image3.png',
];
preloadimg(imgs, success => {
console.log(success);
}, fail => {
console.log(fail)
}, () => {
console.log('all images preload completely!')
});
</script>
Use in ES6 modules or CommonJS
import preloadimg from 'preloadimg';
preloadimg([
'img/image1.png',
'img/image2.png',
'img/image3.png',
], success => {
console.log(success);
}, fail => {
console.log(fail)
}, () => {
console.log('all images preload completely!')
});