1.0.6 • Published 4 years ago

preload-all v1.0.6

Weekly downloads
12
License
MIT
Repository
github
Last release
4 years ago

English | 简体中文

preload-all

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.

Install

npm i preload-all --save

Options

paramdescvaluestypemust
linksresource list[]string[]yes
typeresource typeimage/js/css/''stringno
ignoreIgnore loading exception resourcestrue/falsebooleanno
retryNumber of failed retries of resource loading0numberno

Usage

First

import {preloadAll} from 'preload-all';

Preload all resource

preloadAll({
    links: [
        "https://xxx01.jpg",        //Image
        "https://xxx02.js",         //Js
        "https://xxx03.css",        //Css
    ]
}).then((res)=>{
    //todo success
}).catch((error)=>{
    //todo fail
})

Preload Image

preloadAll({
    links: [
        "https://xxx01.jpg",
        "https://xxx02.png",
        "https://xxx03.gif",
    ],
    type: 'image'
})

Preload Js

preloadAll({
    links: [
        "https://xxx01.js",
        "https://xxx02.js",
        "https://xxx03.js",
    ],
    type: 'js'
})

Preload Css

preloadAll({
    links: [
        "https://xxx01.css",
        "https://xxx02.css",
        "https://xxx03.css",
    ],
    type: 'css'
})