2.0.0 • Published 8 years ago

@f/load-image v2.0.0

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

load-image

Build status Git tag NPM version Code style

Load an image in the browser to ensure it is available to be rendered immediately

Installation

$ npm install @f/load-image

Usage

var loadImage = require('@f/load-image')

function allImagesLoaded () {
  return Promise.all(
  [].slice.call(document.querySelectorAll('img')).map(img => loadImage(img.getAttribute('src')))
}

API

loadImage(url)

  • url - Url of the image you want to load

Returns: A promise that resolves when the image is loaded or rejects if an error occurs.

License

MIT