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 |