Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@area17/a17-lazyload

Package Overview
Dependencies
Maintainers
7
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@area17/a17-lazyload

A simple, tiny, no dependency, lazy loader - by A17

  • 0.1.7
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
16
increased by60%
Maintainers
7
Weekly downloads
 
Created
Source

A17 Lazy Load

  • Demos https://area17.github.io/lazyload/
  • Issues https://github.com/area17/lazyload/issues

Introduction

A straight forward lazy loader using IntersectionObserver if available and if not, it uses a requestAnimationFrame loop if available. If neither are available it does nothing.

When a watched element is in the view port it swaps data-src/data-srcset on img, source and iframe to src/srcset. It also adds a load listener and removes the data- attribute on load to allow you to hook styles up to the two different states.

If data-srcset to srcset and typeof picturefill, attempts to run picturefill() on the element.

When it runs out of elements to watch, the loop ends.

More detailed instructions on usage are at: https://area17.github.io/lazyload/

Usage

<script src="path/to/a17-lazyload.min.js"></script>
<script>
  lazyload();
</script>

Also available via NPM:

npm install @area17/a17-lazyload
import lazyload from '@area17/a17-lazyload';

lazyload();

Issues/Contributing/Discussion

If you find a bug in a17-lazyload, please add it to the issue tracker or fork it, fix it and submit a pull request for it (👍).

The development script is dist/a17-lazyload.js. Tabs are 2 spaces, functions are commented, variables are camel case and its preferred that its easier to read than outright file size being the smallest possible.

Make sure to include a minified version inside of dist by running: npm run minify (you'll need to npm run install to install terser). The minified version is added to the git repository for users who aren't using build tools.

Support

IE10+ because of the use of requestAnimationFrame if no IntersectionObserver.

Coming soon

Filesize

  • ~8kb uncompressed
  • ~3kb minified
  • ~1kb minified and gzipped

FAQs

Package last updated on 17 May 2023

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

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc