Wait for images to load using promises
$ npm install --save images-loaded
const imagesLoaded = require('images-loaded');
imagesLoaded('.container').then(elements => {
// images are hot and ready
});Returns a Promise when all images are done loading, with or without errors.
Type: string Element NodeList
A container or list of elements to watch for loading images.
Type: Object
Type: string[]
Default: []
Can be passed a list of DOM style camelCase properties to check. For example, backgroundImage, borderImage, etc.
Type: string[]
Default: []
Can be passed a list of attributes to check, such as poster in a video tag.
If your browser supports Promise then 🎉. Check it at caniuse.com.
MIT © Alex Cross