popoload

Load script and css.

Usage no npm install needed!

<script type="module">
  import popoload from 'https://cdn.skypack.dev/popoload';
</script>

README

Script and Style file resource load tool

中文介绍

In some application scenarios, we need to customize the loading of certain Javascript plug-ins based on configuration, usually including plug-in dependency scripts and styles. Pooload can load plug-ins and their dependencies through configuration.

Install

npm i popoload

or

<script src="./js/popoload.min.js"></script>

Use


PL({
    config: {
        path: {
            bootcdn: 'https://cdn.bootcss.com/'
        }
    },
    libs: [
        'bootcdn:jquery/3.1.1/jquery.min.js',
        'bootcdn:leaflet/1.3.1/leaflet.js'
    ],
    styles: [
        'bootcdn:leaflet/1.3.1/leaflet.css'
    ],
    loaded: function() {
        if($ && L) {
            $(document.body).html('All resource loaded.');
        }
    }
});

Config Options

|Params|Type|Note| |-|-|-| |config|Object|config path.| |config.path|Object|key-value, Key is a reference and value is the actual reference path.| |libs|Array|Depending on the library script list, the value is key + ":" + dependency library file defined in config.path.| |styles|Array|Depending on the library script list, the value is key + ":" + dependency library file defined in config.path.| |loaded|Function|Load completion callback method|