https://github.com/pspgbhu/preloadimg
🌅 A library for preload images
https://github.com/pspgbhu/preloadimg
preload preload-image preload-images preloadimg
Last synced: 11 months ago
JSON representation
🌅 A library for preload images
- Host: GitHub
- URL: https://github.com/pspgbhu/preloadimg
- Owner: pspgbhu
- License: mit
- Created: 2017-05-12T17:26:10.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-10T03:13:56.000Z (about 9 years ago)
- Last Synced: 2025-06-09T16:46:24.527Z (about 1 year ago)
- Topics: preload, preload-image, preload-images, preloadimg
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# preloadimg
[](https://www.npmjs.org/package/preloadimg)
[](https://npmjs.org/package/preloadimg)
A library for preload images
---
## Install
`npm install --save preloadimg`
## Usage
Use in script tag
```html
var imgs = [
'img/image1.png',
'img/image2.png',
'img/image3.png',
];
preloadimg(imgs, success => { // everyone image preloaded success
console.log(success);
}, fail => { // everyone image preloaded fail
console.log(fail)
}, () => { Â // it will be called when all images preloaded whatever succeeded or failed
console.log('all images preload completely!')
});
```
Use in ES6 modules or CommonJS
```js
// in ES6 modules
import preloadimg from 'preloadimg';
// in CommonJS
// var preloadimg = require('preloadimg');
preloadimg([
'img/image1.png',
'img/image2.png',
'img/image3.png',
], success => { // everyone image preloaded success
console.log(success);
}, fail => { // everyone image preloaded fail
console.log(fail)
}, () => { Â // it will be called when all images preloaded whatever succeeded or failed
console.log('all images preload completely!')
});
```