Minimal Fullscreen Image Preloader – Preloader.js

Category: Javascript , Loading | July 27, 2015
Author: yhb241
Views Total: 3,564
Official Page: Go to website
Last Update: July 27, 2015
License: MIT

Preview:

Minimal Fullscreen Image Preloader – Preloader.js

Description:

Preloader.js is a super lightweight JavaScript library that displays a fullscreen overlay with custom loading text until all the specified images have been loaded.

How to use it:

Create the html for the image preloader.

<div class="preloader" id="preloader">
  <div>Loading...</div>
</div>

Load the preloader.js script in the document.

<script src="js/preloader.js"></script>

Create an array of images you want to preload and then initialize the image preloader.

'use strict';
window.addEventListener('DOMContentLoaded', function(){
  preloader.init({
    id: 'preloader',
    imgUrls: ['1.jpg', '2.jpg', '3.jpg'],
    onInit: function(){
      // do something
    },
    onRemove: function(){
      // do something
    }
  });
}, false);

You Might Be Interested In:


Leave a Reply