
Product
Introducing Webhook Events for Alert Changes
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.
Dependency-free library for lazyloading iframes. Demo
Because embedded content takes time to load.
Lazyframe creates a responsive placeholder for embedded content and requests it when the user interacts with it. This decreases the page load and idle time.
Lazyframe comes with brand-like themes for Youtube and Vimeo.
NPM
$ npm install lazyframe --save
Bower
$ bower install lazyframe
JavaScript ES6 imports
import lazyframe from "lazyframe";
Include JavaScript in html
<script src="dist/lazyframe.min.js"></script>
Sass import
@import 'src/scss/lazyframe'
Include css in html
<link rel="stylesheet" href="dist/lazyframe.css" />
// Passing a selector
lazyframe(".lazyframe");
// Passing a nodelist
let elements = document.querySelectorAll(".lazyframe");
lazyframe(elements);
// Passing a jQuery object
let elements = $(".lazyframe");
lazyframe(elements);
You can pass general options to lazyframe on initialization. Element-specific options (most options) are set on data attributes on the element itself.
General options and corresponding defaults
lazyframe(elements, {
debounce: 250,
lazyload: true,
autoplay: true,
// Callbacks
onLoad: (lazyframe) => console.log(lazyframe),
onAppend: (iframe) => console.log(iframe),
onThumbnailLoad: (img) => console.log(img),
});
debounceValue (in milliseconds) for when the update function should run after the user has scrolled. More here
lazyloadSet this to false if you want all API calls and local images to be loaded on page load (instead of when the element is in view).
autoplaySet this to false to remove autoplay from the allow attribute on the iframe tag i.e if set this to false if you want don't want your Youtube video to automatically start playing once the user clicks on the play icon.
onLoadCallback function for when a element is initialized.
onAppendCallback function for when the iframe is appended to DOM.
onThumbnailLoadCallback function with the thumbnail URL
<div
class="lazyframe"
data-vendor=""
data-title=""
data-thumbnail=""
data-src=""
data-ratio="1:1"
data-initinview="false"
data-autoplay="false"
></div>
data-vendorAttribute for theming lazyframe. Currently supported values are youtube, youtube_nocookie and vimeo.
data-titleAttribute for custom title. Leave empty to get value from noembed.com.
data-thumbnailAttribute for custom thumbnail. Leave empty to get value from noembed.com.
data-srcThe source of what you want to lazyload.
data-ratioThe ratio of the lazyframe. Possible values: 16:9, 4:3, 1:1
data-initinviewSet this to true if you want the resource to execute (for example video to play) when the element is in view.
MIT. © 2016 Viktor Bergehall
FAQs
Dependency-free library for lazyloading iframes
The npm package lazyframe receives a total of 1,163 weekly downloads. As such, lazyframe popularity was classified as popular.
We found that lazyframe demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
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.

Product
Add real-time Socket webhook events to your workflows to automatically receive software supply chain alert changes in real time.

Security News
ENISA has become a CVE Program Root, giving the EU a central authority for coordinating vulnerability reporting, disclosure, and cross-border response.

Product
Socket now scans OpenVSX extensions, giving teams early detection of risky behaviors, hidden capabilities, and supply chain threats in developer tools.