justlazy.js is a lightweight javascript plugin for responsive image loading. Most of the current javascript plugins use extensive dependencies or only support the img
tag with no responsive parts. This plugin is meant to be an alternative.
- 100% performance using plain javascript (no jQuery).
- 100% valid HTML (no empty src tag).
- Simplicity and lightness (only lazy loading of images, no special cases).
- Extensively tested on various devices, browsers, and OS versions.
lazy load images example, lazy load images jquery, lazy load background images, lazy loading javascript on scroll, lazy load images html, lazy loading example
How to make use of it:
1. Install, download, and import the following JavaScript and CSS files into your document.
# NPM $ npm install justlazy --save
<link rel="stylesheet" href="stylesheets/justlazy.css"> <script src="javascript/justlazy.js"></script>
2. Insert the image you want to load slowly using the following HTML data attributes:
<div class="load-if-visible-placeholder justlazy-spinner" data-src="1.jpg" data-alt="Image Alt" data-title="Image Title"> </div>
3. Activate the lazy load image plugin.
Justlazy.registerLazyLoadByClass("load-if-visible-placeholder");
4. Specify the millisecond limit in which the xxx pixel image will be loaded before it becomes visible on the screen.
Justlazy.registerLazyLoadByClass("load-if-visible-placeholder",{ threshold: 300 });
5. Callback functions:
Justlazy.registerLazyLoadByClass("load-if-visible-placeholder",{ // Optional callback which is invoked after the image is loaded successfully but before the actual replacement. onloadCallback: function(){}, // Optional error handler which is invoked before the actual replacement if the image could not be loaded. onerrorCallback: function(){}, // Optional callback which is invoked directly after the replacement of the placeholder. onreplaceCallback: function(){}, });
image lazy load with custom events, justlazy.js Plugin/Github
See Demo And Download
Official Website(fhopeman): Click Here
This superior jQuery/javascript plugin is developed by fhopeman. For extra advanced usage, please go to the official website.