chck-imgs
v0.0.2
Published
Lightweight JavaScript plugin to check if one or multiple images are loaded
Downloads
10
Readme
Chck Imgs
chckImgs
is a lightweight (< 400 bytes gzipped) JavaScript plugin to check if one or multiple images are loaded.
Install
NPM
npm install --save chck-imgs
Bower
bower install --save chck-imgs
Usage
/**
* `chckImgs` will always resolve with an array, even if one or multiple images failed to load.
* You can loop through this array and check the `status` (`ok` or `error`) for each image
*
* @param {...String} paths
* @return {Promise.<{{path: String, status: String}}>}
*/
chckImgs('img.jpg', 'img2.jpg').then(function(imgs) {
// All images are either loaded or failed to load. If necessary, you can loop over the
// `imgs` array to check the `status`
});
Browser Support
All major browsers are supported (IE9+). You'll have to polyfill ES6 Promises
for browsers that do not support native Promises yet.
Local Development
To compile and compress chckImgs.js
, we rely on npm as a Build Tool.
Setup
Check out the repository
git clone [email protected]:mrksbnch/chck-imgs.git cd chck-imgs
Run
npm install
to install all dependencies
Workflow
| NPM command | Description |
| ----------------------------- | ---------------------------------------------------------------- |
| npm run lint
| (es)lint JavaScript |
| npm run uglify
| Compress JavaScript |
| npm run babel
| Compile ES6 to ES5 with Babel |
| npm run build
| Lint, compress and minify JavaScript |
| npm run watch
| Watch file changes |
Copyright
Copyright 2016 Markus Bianchi. See LICENSE for details.