Socket
Socket
Sign inDemoInstall

lazy-iframe

Package Overview
Dependencies
684
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    lazy-iframe

Web component to help you lazy load iframes


Version published
Weekly downloads
530
increased by18.57%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Built With Stencil

lazy-iframe

lazy-iframe is a web component built with stencil that lets you lazy load iframes as the user scrolls over them. It uses the intersectionObserver to achieve this functionality. This can be handy for embedding youtube videos, ads that work through an iframe etc.

API

  • src(string): the src of the asset you want to load in the iframe
  • title(string): the title for the iframe

Styling

lazy-iframe exposes two css variables to enable easy styling of the iframe. Here is a usage example:

// in your apps css

:root {
  --iframe-width: 100px;
  --iframe-height: 100px;
}

Usage

 <lazy-iframe src='https://www.youtube.com/embed/UfD-k7aHkQE' title='ionic and stencil'></lazy-iframe>

Script tag

  • Publish to NPM
  • Put a this script tag <script src='https://unpkg.com/lazy-iframe@0.0.3/dist/lazyiframe.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

Node Modules

  • Run npm install my-name --save
  • Put a script tag similar to this <script src='node_modules/lazy-iframe/dist/lazyiframe.js></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install lazy-iframe --save
  • Add { name: 'lazy-iframe' } to your collections
  • Then you can use the element anywhere in your template, JSX, html etc

FAQs

Last updated on 04 Oct 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc