Tiny Image Defer Loading Library – Img Defer

Category: Image , Loading | December 28, 2016
Author: jenstornell
Views Total: 2,080
Official Page: Go to website
Last Update: December 28, 2016
License: MIT


Tiny Image Defer Loading Library – Img Defer


A super tiny JavaScript library which has the ability to defer the loading of images until the DOM content has finished loading.

How to use it:

Embed an image into the document using the data-src attribute. The regular src attribute is used to specify the path to the placeholder image as this:

<img class="defer" 

Load the core JavaScript file img-defer.js at the end of your html document.

<script src="img-defer.js"></script>

Initialize the Img Defer and specify the selector containing images you’d like to defer loading.

document.addEventListener("DOMContentLoaded", function(event) {
      selector: '.defer'

You Might Be Interested In:

Leave a Reply