Skip to content

async-assets-loader loads assets asynchronously (js files, css styles, images) and triggers a callback after all is loaded

License

Notifications You must be signed in to change notification settings

vbabak/async-assets-loader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-assets-loader

NPM Version License: MIT NPM Downloads

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

asyncAssetsLoader()

Contribution Notes

Clone project on github

Install libraries

npm i

Build & Test

npm test

Open Pull Request

Make changes and create a merge request.

About

async-assets-loader loads assets asynchronously (js files, css styles, images) and triggers a callback after all is loaded

Resources

License

Stars

Watchers

Forks

Packages

No packages published