Socket
Book a DemoInstallSign in
Socket

lazy-load-images

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazy-load-images

A Live on Stage plugin to lazy load images.

1.0.1
latest
Source
npmnpm
Version published
Weekly downloads
1.1K
-52.71%
Maintainers
1
Weekly downloads
 
Created
Source

Lazy Load Images

A Live on Stage plugin to load images only when they appear on screen.

Install

NPM

First install Lazy Load Images in your project root:

$ npm install lazy-load-images

Then include in your module using require() and run the init method:

var lazyLoadImages = require('lazy-load-images');

lazyLoadImages.init();

Use

By default, Lazy Load Images tracks images with a data-lazy-load-src attribute:

<img data-lazy-load-src="/foo/bar.png" />

When an image is successfully downloaded, the img element will be given a lazy-loaded class which you can use as a hook in your CSS to fade the image in.

A lazy loaded image tag will look like this:

<img src="/foo/bar.png" data-lazy-load-src="/foo/bar.png" class="lazy-loaded" />

New images

When the DOM changes, it's necessary to rescan the page for new images with a data-lazy-load-src tag. Simply use the refresh method:

lazyLoadImages.refresh();

Keywords

viewport

FAQs

Package last updated on 01 Apr 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.