async-assets-loader
loads assets asynchronously (js files, css styles, images) and triggers a callback after all is loaded.
Package is compatible with the most of browsers and NPM (UMD).
<script src="https://unpkg.com/async-assets-loader"></script>
<script>
var jsfile = "https://code.jquery.com/jquery-3.4.1.min.js";
var cssfile = "https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css";
var imgfile = "https://logos.keycdn.com/keycdn-logo-black.png";
var assetsLoader = new asyncAssetsLoader();
assetsLoader.load([
{url: jsfile, type: "script"},
{url: cssfile, type: "style"},
{url: imgfile, type: "img"}
], function () {
console.log("Assets are loaded");
console.log("Img width: " + assetsLoader.getLoadedTags()[imgfile].width);
});
</script>
# bash
npm i async-assets-loader
// js
const assetsLoader = require("async-assets-loader");
Clone project on github
npm i
npm test
Make changes and create a merge request.