Any Resources Preloader JavaScript Library – Loader.js

Category: Javascript , Loading | December 21, 2018
Author: anuraghazra
Views Total: 375
Official Page: Go to website
Last Update: December 21, 2018
License: MIT

Preview:

Any Resources Preloader JavaScript Library – Loader.js

Description:

Loader.js is a pure JavaScript preloader that preloads web resources (text, JSON, images, audios, videos, etc) and triggers certain events while loading and after loaded.

How to use it:

Insert the Loader.js into the html page.

<script src="./dist/Loader.js"></script>

Initialize the preloader.

let myLoader = new LoaderJS();

Preload web resources using the following syntax:

// preload text
loader.loadString('myText', './text.txt');

// preload JSON
loader.loadJSON('myData', './data.json');

// preload image
loader.loadImage('myImg', './img.jpg');

// preload media
loader.loadMedia('myAudio', './audio.mp3');
loader.loadMedia('myVideo', './video.mp4');

Do something when the files are loading.

myLoader.whileLoading = function() {
  // do something 
}

Do something when the files are completely loaded.

myLoader.whenReady = function() {
  console.log(loader.assets);
}

You Might Be Interested In:


Leave a Reply