Any Resources Preloader JavaScript Library – Loader.js

Category: Javascript , Loading | April 4, 2019
Author:anuraghazra
Views Total:3,205 views
Official Page:Go to website
Last Update:April 4, 2019
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 video
loader.loadVideo('myVideo', './video.mp4');
// preload Audio, Video or media blobs
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);
}

Changelog:

04/04/2019

  • Added loadVideo

You Might Be Interested In:


Leave a Reply