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

lazyvids

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lazyvids - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

2

dist/lazyvids.js

@@ -1,1 +0,1 @@

(t=>{window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),document.addEventListener("DOMContentLoaded",()=>{const a={logLevel:t&&t.logLevel?t.logLevel:"silent",ignoreHidden:t&&t.ignoreHidden?t.ignoreHidden:!1,minBandwidth:t&&t.minBandwidth?Number.parseFloat(t.minBandwidth):0,reduceData:t&&t.reduceData?t.reduceData:!1,requirePoster:t&&t.requirePoster?t.requirePoster:!0},f=(e,r="")=>{a.logLevel==="verbose"&&window.console.log(`lazyvids: ${e}`,r)},s=(e,r="")=>{a.logLevel!=="silent"&&window.console.warn(`lazyvids: ${e}`,r)},u=typeof window.IntersectionObserver=="function";let c;if(a.reduceData&&a.minBandwidth&&navigator.connection&&navigator.connection.downlink&&(navigator.connection.downlink<a.minBandwidth||navigator.connection.saveData)){s(`Slow connection (${navigator.connection.downlink}mbps). Lazy autoplay disabled.`);return}const o=e=>{e.playsinline=!0,e.muted=!0,e.autoplay=!0,e.play()!==void 0?e.play().then(()=>e.dataset.lazyvids="loaded").catch(r=>s("Autoplay blocked by browser for:",e)):e.dataset.lazyvids="loaded"},y=e=>{if(e.style&&e.style.display&&e.style.display==="none"||a.ignoreHidden&&e.style&&e.style.visibility&&e.style.visibility==="hidden")return!1;const r=getComputedStyle(e);return r.getPropertyValue("display")==="none"||a.ignoreHidden&&r.getPropertyValue("visibility")==="hidden"?!1:e.parentNode&&e.parentNode!==document?y(e.parentNode):!0},v=(e,r)=>{e.forEach(n=>{window.requestAnimationFrame(()=>{const i=n.target;n.isIntersecting!==!1&&y(i)!==!1&&(o(i),r.unobserve(i))})})};u&&(c=new IntersectionObserver(v));const d=e=>{if(a.requirePoster&&(e.poster===void 0||e.poster==="")){o(e),s("Video missing poster image. Lazy autoplay disabled for:",e);return}if(u===!1){o(e),s("Unsupported browser. Lazy autoplay disabled.");return}e.dataset.lazyvids="unloaded",c.observe(e)},p="video[data-lazyvids]:not([data-lazyvids=loaded])",l=document.querySelectorAll(p);f(`Initialised \u2014 ${l.length} ${l.length===1?"video":"videos"} detected`),l.forEach(e=>d(e));const w=e=>{e.forEach(r=>{r.addedNodes.forEach(n=>{if(n.tagName==="VIDEO"&&n.dataset.lazyvids!==void 0&&n.dataset.lazyvids!=="loaded"){d(n);return}if(n.hasChildNodes()===!1)return;const i=n.querySelectorAll(p);i.length!==0&&i.forEach(g=>d(g))})})},h={childList:!0,subtree:!0};new MutationObserver(w).observe(document,h)})})(window.lazyvidsConfig||{});
(t=>{window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),document.addEventListener("DOMContentLoaded",()=>{const n={logLevel:t&&t.logLevel?t.logLevel:"silent",ignoreHidden:t&&t.ignoreHidden?t.ignoreHidden:!1,minBandwidth:t&&t.minBandwidth?Number.parseFloat(t.minBandwidth):0,reduceData:t&&t.reduceData?t.reduceData:!1,requirePoster:t&&t.requirePoster?t.requirePoster:!0},f=(e,r="")=>{n.logLevel==="verbose"&&window.console.log(`lazyvids: ${e}`,r)},i=(e,r="")=>{n.logLevel!=="silent"&&window.console.warn(`lazyvids: ${e}`,r)},u=typeof window.IntersectionObserver=="function";let y;if(n.reduceData&&n.minBandwidth&&navigator.connection&&navigator.connection.downlink&&(navigator.connection.downlink<n.minBandwidth||navigator.connection.saveData)){i(`Slow connection (${navigator.connection.downlink}mbps). Lazy autoplay disabled.`);return}const o=e=>{e.playsinline=!0,e.muted=!0,e.autoplay=!0,e.play()!==void 0?e.play().then(()=>e.dataset.lazyvids="loaded").catch(r=>i("Autoplay blocked by browser for:",e)):e.dataset.lazyvids="loaded"},c=e=>{if(e.style&&e.style.display&&e.style.display==="none"||n.ignoreHidden&&e.style&&e.style.visibility&&e.style.visibility==="hidden")return!1;const r=getComputedStyle(e);return r.getPropertyValue("display")==="none"||n.ignoreHidden&&r.getPropertyValue("visibility")==="hidden"?!1:e.parentNode&&e.parentNode!==document?c(e.parentNode):!0},v=(e,r)=>{e.forEach(a=>{window.requestAnimationFrame(()=>{const s=a.target;a.isIntersecting!==!1&&c(s)!==!1&&(o(s),r.unobserve(s))})})};u&&(y=new IntersectionObserver(v));const d=e=>{if(n.requirePoster&&(e.poster===void 0||e.poster==="")){o(e),i("Video missing poster image. Lazy autoplay disabled for:",e);return}if(u===!1){o(e),i("Unsupported browser. Lazy autoplay disabled.");return}e.dataset.lazyvids="unloaded",y.observe(e)},p="video[data-lazyvids]:not([data-lazyvids=loaded]):not([data-lazyvids=false])",l=document.querySelectorAll(p);f(`Initialised \u2014 ${l.length} ${l.length===1?"video":"videos"} detected`),l.forEach(e=>d(e));const w=e=>{e.forEach(r=>{r.addedNodes.forEach(a=>{if(a.tagName==="VIDEO"&&a.dataset.lazyvids!==void 0&&a.dataset.lazyvids!=="loaded"&&a.dataset.lazyvids!=="false"){d(a);return}if(a.hasChildNodes()===!1)return;const s=a.querySelectorAll(p);s.length!==0&&s.forEach(g=>d(g))})})},h={childList:!0,subtree:!0};new MutationObserver(w).observe(document,h)})})(window.lazyvidsConfig||{});
{
"name": "lazyvids",
"version": "0.2.1",
"version": "0.2.2",
"description": "A small utility to lazy-load autoplay HTML5 videos once they enter the viewport.",

@@ -5,0 +5,0 @@ "main": "dist/lazyvids.js",

@@ -158,3 +158,4 @@ ((configObj) => {

*/
const domSelector = 'video[data-lazyvids]:not([data-lazyvids=loaded])';
const domSelector =
'video[data-lazyvids]:not([data-lazyvids=loaded]):not([data-lazyvids=false])';
const lazyVideos = document.querySelectorAll(domSelector);

@@ -181,3 +182,4 @@ log(

node.dataset.lazyvids !== undefined &&
node.dataset.lazyvids !== 'loaded'
node.dataset.lazyvids !== 'loaded' &&
node.dataset.lazyvids !== 'false'
) {

@@ -184,0 +186,0 @@ process(node);

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