@wbe/preloads
v2.3.0
Published
Preloads assets utilities
Downloads
12
Readme
@wbe/preloads
Preloads assets utilities:
Installation
$ npm install -s @wbe/preloads
preloadImage
Parameters
url (string)
: image URL
Returns
(Promise<HTMLImageElement>)
: Promise who return image element
Example
import { preloadImage } from "@wbe/preloads";
preloadImage("https://picsum.photos/200/300").then((response) => {
// image is loaded, do something...
});
preloadImages
Parameters
urls (string[])
: image URLs array
Returns
(Promise<HTMLImageElement[]>)
: Promise who return image elements array
Example
import { preloadImages } from "@wbe/preloads";
preloadImages([
"https://picsum.photos/200/300",
"https://picsum.photos/200/300",
]).then((response) => {
// images are loaded, do something...
});