Lightweight Javascript Plugin for Image Lazy Loading | justlazy.js

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.

Related Posts

VenoBox-Responsive-jQuery-Lightbox-Plugin

Responsive Image Gallery Lightbox jQuery Plugin | VenoBox

VenoBox is a responsive jQuery modal window plugin suitable for images, embedded content, iFrames, Google Maps, Vimeo, and YouTube videos. The big difference compared to many other…

bootstrap-dropdown-on-hover

[Animation] Bootstrap Multi-Level Responsive Dropdown Menu

Bootstrap-based multi-level dropdown navigation menu with cool animations. The dropdown on Hover is a jQuery plugin used to create Bootstrap multi-level scroll-triggered dropdown menus with CSS3 animations…

Google-Translate-Dropdown-Customize-With-Country-Flag

Google Translate Dropdown Customize With Country Flag | GT API

Flag google translates jQuery text that takes advantage of the Google Cloud Translation API to translate web content between languages by selecting a country from the dropdown…

Bootstrap-Fileinput

HTML 5 File Input Optimized for Bootstrap 4.x./3.x with File Preview | Bootstrap Fileinput

bootstrap-fileinput is an improved HTML 5 file input  Bootstrap 5.x, 4.x and 3.x with file preview for different files, provides multiple selections, resumable section uploads, and more….

HStack-and-VStack-in-CSS

CSS Layout Components Horizontal/Vertical Stack | HStack and VStack

HStack and VStack in CSS – CSS layout components that (basically) stack anything horizontally and vertically. A pure CSS library that makes it easy to stack elements…

Floating-Whatsapp-Chat-Button

How to Add Floating Whatsapp Chat Button In HTML | venom-button

Venom Button is a very simple plugin for the jQuery floating WhatsApp button. Adds a floating button to your site that calls WhatsApp Click to Chat API. It will automatically start the WhatsApp…

Leave a Reply

Your email address will not be published. Required fields are marked *