img-load

2.0.0 • Public • Published

img-load

tiny promise-based <img> loader for the browser

loadImage("images/foo.png")
  .then(image => document.body.appendChild(image))

usage

npm badge

loadImage(path)

Returns a Promise which resolves to the image indicated by path.

Consider using loadImage within an async function to further simplify usage.

import loadImage from "img-load"
 
async function main() {
  let foo = await loadImage("images/foo.png")
  let bar = await loadImage("images/bar.png")
  // use `foo.png` and `bar.png`
}
 
main()

Package Sidebar

Install

npm i img-load

Weekly Downloads

0

Version

2.0.0

License

MIT

Unpacked Size

2.64 kB

Total Files

4

Last publish

Collaborators

  • semibran