function resource_loader(config) {
this.css = config.css;
this.scripts = config.scripts;
this.head = document.getElementsByTagName('head')[0];
this.v = '?v=' + new Date().getTime();
this.load = function() {
this.loadCSS();
this.loadScript();
}
this.loadScript = function() {
var that = this;
this.scripts.forEach(function(scriptlink) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = scriptlink + this.v;
this.head.appendChild(script);
});
}
this.load();
return resource_loader
}
<script>
$(function() {
resource_loader({
css: [
'layui/adminIndex.css'
],
scripts: [
'layui/adminIndex.js'
]
});
})
</script>