preload-all

1.0.6 • Public • Published

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

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

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'
})

Package Sidebar

Install

npm i preload-all

Weekly Downloads

27

Version

1.0.6

License

MIT

Unpacked Size

6.17 kB

Total Files

5

Last publish

Collaborators

  • xkh