0.0.2 • Published 8 years ago

chck-imgs v0.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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

  1. Check out the repository

    git clone git@github.com:mrksbnch/chck-imgs.git
    cd chck-imgs
  2. Run npm install to install all dependencies

Workflow

NPM commandDescription
npm run lint(es)lint JavaScript
npm run uglifyCompress JavaScript
npm run babelCompile ES6 to ES5 with Babel
npm run buildLint, compress and minify JavaScript
npm run watchWatch file changes

Copyright

Copyright 2016 Markus Bianchi. See LICENSE for details.