New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

lazy-img-element

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-img-element

Custom, production-ready HTML element (`<lazy-img>`) that lazily loads images as they come on to the screen.

  • 0.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Lazy Image Custom Element

npm version

Custom, production-ready HTML element (<lazy-img>) that lazily loads images as they come on to the screen.

Getting the Element

Please see the releases page to get the latest, minified version of the source for the <lazy-img>. Import into your project as needed.

The element is built on top of the custom element API, and uses the newer IntersectionObserver API.

If you just need to polyfill the IntersectionObserver, you can add the following:

<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>

If you need to polyfill web components, please see webcomponents.org/polyfills/

Using the Element

The element is a 1-to-1 copy of the standard HTML <img /> element, so all in-spec attributes and features should also be available to <lazy-img> elements as well.

Example:

<lazy-img src="..."></lazy-img>

Aspect Ratio Space

In addition to all normal features of the <img /> tag, you can specify a ratio attribute so that the <lazy-img> will occupy the proper space on the page while the image is loading. To do so, specify an aspect ratio like: [width]:[height].

Example:

<lazy-img src="..." ratio="16:9"></lazy-img>

Keywords

FAQs

Package last updated on 17 Nov 2017

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