English | 简体中文
Preload all resources,image、js、css... Super small size
1.7K
Support multi-format resource loading and automatic suffix recognition. It is recommended to carry the value of type type to reduce the loading time. return
Promise, Usage examples adopt.then .catch, Of course you can use itasync await.
npm i preload-all --save| param | desc | values | type | must |
|---|---|---|---|---|
| links | resource list | [] | string[] | yes |
| type | resource type | image/js/css/'' | string | no |
| ignore | Ignore loading exception resources | true/false | boolean | no |
| retry | Number of failed retries of resource loading | 0 | number | no |
import {preloadAll} from 'preload-all';preloadAll({
links: [
"https://xxx01.jpg", //Image
"https://xxx02.js", //Js
"https://xxx03.css", //Css
]
}).then((res)=>{
//todo success
}).catch((error)=>{
//todo fail
})preloadAll({
links: [
"https://xxx01.jpg",
"https://xxx02.png",
"https://xxx03.gif",
],
type: 'image'
})preloadAll({
links: [
"https://xxx01.js",
"https://xxx02.js",
"https://xxx03.js",
],
type: 'js'
})preloadAll({
links: [
"https://xxx01.css",
"https://xxx02.css",
"https://xxx03.css",
],
type: 'css'
})