async-assets-loader
v1.2.0
Published
async-assets-loader loads assets asynchronously (js files, css styles, images) and triggers a callback after all is loaded
Downloads
587
Maintainers
Readme
async-assets-loader
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).
Examples
Browser
<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>
NPM
# bash
npm i async-assets-loader
// js
const assetsLoader = require("async-assets-loader");
Source Code
Contribution Notes
Clone project on github
Install libraries
npm i
Build & Test
npm test
Open Pull Request
Make changes and create a merge request.