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

lozad

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lozad - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

17

dist/lozad.es.js

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

/*! lozad.js - v1.7.0 - 2018-11-08
/*! lozad.js - v1.8.0 - 2019-01-31
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2018 Apoorv Saxena; Licensed MIT */
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */

@@ -27,2 +27,15 @@

}
if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {
if (element.children) {
const childs = element.children;
let childSrc;
for (let i = 0; i <= childs.length - 1; i++) {
childSrc = childs[i].getAttribute('data-src');
if (childSrc) {
childs[i].src = childSrc;
}
}
element.load();
}
}
if (element.getAttribute('data-src')) {

@@ -29,0 +42,0 @@ element.src = element.getAttribute('data-src');

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

/*! lozad.js - v1.7.0 - 2018-11-08
/*! lozad.js - v1.8.0 - 2019-01-31
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2018 Apoorv Saxena; Licensed MIT */
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */

@@ -35,2 +35,15 @@

}
if (element.nodeName.toLowerCase() === 'video' && !element.getAttribute('data-src')) {
if (element.children) {
var childs = element.children;
var childSrc = void 0;
for (var i = 0; i <= childs.length - 1; i++) {
childSrc = childs[i].getAttribute('data-src');
if (childSrc) {
childs[i].src = childSrc;
}
}
element.load();
}
}
if (element.getAttribute('data-src')) {

@@ -37,0 +50,0 @@ element.src = element.getAttribute('data-src');

8

dist/lozad.min.js

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

/*! lozad.js - v1.7.0 - 2018-11-08
/*! lozad.js - v1.8.0 - 2019-01-31
* https://github.com/ApoorvSaxena/lozad.js
* Copyright (c) 2018 Apoorv Saxena; Licensed MIT */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lozad=e()}(this,function(){"use strict";var g=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},r="undefined"!=typeof document&&document.documentMode,l={rootMargin:"0px",threshold:0,load:function(t){if("picture"===t.nodeName.toLowerCase()){var e=document.createElement("img");r&&t.getAttribute("data-iesrc")&&(e.src=t.getAttribute("data-iesrc")),t.getAttribute("data-alt")&&(e.alt=t.getAttribute("data-alt")),t.appendChild(e)}t.getAttribute("data-src")&&(t.src=t.getAttribute("data-src")),t.getAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset")),t.getAttribute("data-background-image")&&(t.style.backgroundImage="url('"+t.getAttribute("data-background-image")+"')"),t.getAttribute("data-toggle-class")&&t.classList.toggle(t.getAttribute("data-toggle-class"))},loaded:function(){}};
* Copyright (c) 2019 Apoorv Saxena; Licensed MIT */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lozad=e()}(this,function(){"use strict";var g=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var o in r)Object.prototype.hasOwnProperty.call(r,o)&&(t[o]=r[o])}return t},n="undefined"!=typeof document&&document.documentMode,l={rootMargin:"0px",threshold:0,load:function(t){if("picture"===t.nodeName.toLowerCase()){var e=document.createElement("img");n&&t.getAttribute("data-iesrc")&&(e.src=t.getAttribute("data-iesrc")),t.getAttribute("data-alt")&&(e.alt=t.getAttribute("data-alt")),t.appendChild(e)}if("video"===t.nodeName.toLowerCase()&&!t.getAttribute("data-src")&&t.children){for(var r=t.children,o=void 0,a=0;a<=r.length-1;a++)(o=r[a].getAttribute("data-src"))&&(r[a].src=o);t.load()}t.getAttribute("data-src")&&(t.src=t.getAttribute("data-src")),t.getAttribute("data-srcset")&&t.setAttribute("srcset",t.getAttribute("data-srcset")),t.getAttribute("data-background-image")&&(t.style.backgroundImage="url('"+t.getAttribute("data-background-image")+"')"),t.getAttribute("data-toggle-class")&&t.classList.toggle(t.getAttribute("data-toggle-class"))},loaded:function(){}};
/**

@@ -9,2 +9,2 @@ * Detect IE browser

* @private
*/function f(t){t.setAttribute("data-loaded",!0)}var b=function(t){return"true"===t.getAttribute("data-loaded")};return function(){var r,o,a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:".lozad",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=g({},l,t),n=e.root,i=e.rootMargin,d=e.threshold,u=e.load,c=e.loaded,s=void 0;return window.IntersectionObserver&&(s=new IntersectionObserver((r=u,o=c,function(t,e){t.forEach(function(t){(0<t.intersectionRatio||t.isIntersecting)&&(e.unobserve(t.target),b(t.target)||(r(t.target),f(t.target),o(t.target)))})}),{root:n,rootMargin:i,threshold:d})),{observe:function(){for(var t=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document;return t instanceof Element?[t]:t instanceof NodeList?t:e.querySelectorAll(t)}(a,n),e=0;e<t.length;e++)b(t[e])||(s?s.observe(t[e]):(u(t[e]),f(t[e]),c(t[e])))},triggerLoad:function(t){b(t)||(u(t),f(t),c(t))},observer:s}}});
*/function f(t){t.setAttribute("data-loaded",!0)}var b=function(t){return"true"===t.getAttribute("data-loaded")};return function(){var r,o,a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:".lozad",t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},e=g({},l,t),n=e.root,i=e.rootMargin,d=e.threshold,c=e.load,u=e.loaded,s=void 0;return window.IntersectionObserver&&(s=new IntersectionObserver((r=c,o=u,function(t,e){t.forEach(function(t){(0<t.intersectionRatio||t.isIntersecting)&&(e.unobserve(t.target),b(t.target)||(r(t.target),f(t.target),o(t.target)))})}),{root:n,rootMargin:i,threshold:d})),{observe:function(){for(var t=function(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:document;return t instanceof Element?[t]:t instanceof NodeList?t:e.querySelectorAll(t)}(a,n),e=0;e<t.length;e++)b(t[e])||(s?s.observe(t[e]):(c(t[e]),f(t[e]),u(t[e])))},triggerLoad:function(t){b(t)||(c(t),f(t),u(t))},observer:s}}});

@@ -5,3 +5,3 @@ {

"description": "A light-weight JS library to lazy load any HTML element such as images, ads, videos etc.",
"version": "1.7.0",
"version": "1.8.0",
"homepage": "https://github.com/ApoorvSaxena/lozad.js",

@@ -8,0 +8,0 @@ "scripts": {

@@ -12,3 +12,4 @@ # Lozad.js [![npm version](https://badge.fury.io/js/lozad.svg)](https://badge.fury.io/js/lozad) [![Build Status](https://travis-ci.org/ApoorvSaxena/lozad.js.svg?branch=master)](https://travis-ci.org/ApoorvSaxena/lozad.js) [![](https://data.jsdelivr.com/v1/package/npm/lozad/badge)](https://www.jsdelivr.com/package/npm/lozad)

- allows lazy loading of dynamically added elements as well,
- supports <img>, <picture>, iframes, videos, audios, responsive images, background images etc.
- supports &lt;img&gt;, &lt;picture&gt;, iframes, videos, audios, responsive images, background images etc.
- is completely free and open source.

@@ -24,2 +25,3 @@ It is written with an aim to lazy load images, iframes, ads, videos or any other element using the recently added [Intersection Observer API](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) with tremendous performance benefits.

- [Codrops](https://twitter.com/Apoorv_Saxena/status/906586828265758720)
- [SitePoint](https://www.sitepoint.com/five-techniques-lazy-load-images-website-performance/)

@@ -75,2 +77,8 @@ ## Table of Contents

---
<a href="https://www.patreon.com/apoorvsaxena">
<img src="https://c5.patreon.com/external/logo/become_a_patron_button@2x.png" width="160">
</a>
## Usage

@@ -213,42 +221,2 @@

## More than 3000 sites are using Lozad.js, here's few of them:
* [gis.utah.gov](https://gis.utah.gov)
* [BNP PARIBAS](https://mabanque.bnpparibas/)
* [Reitmans](https://www.reitmans.com/)
* [Black Desert Online](https://www.blackdesertonline.com/)
* [Tradera](https://www.tradera.com/)
* [Barkers](https://www.barkersonline.co.nz/)
* [Promoda](http://www.promoda.com.mx/)
* [Dormy Golf & Fashion AB](https://www.dormy.se/)
* [L'ovedbaby](https://www.lovedbaby.com/)
* [LitNet](https://litnet.com/)
* [CARD.com](https://www.card.com/)
* [Wittchen](https://www.wittchen.com/)
* [Fiege Group](https://www.fiege.com/)
* [Kolgot](https://kolgot.net/)
* [CYSM - Colombia y su Moda](https://cysm.com/)
* [Siege Media](https://www.siegemedia.com/)
* [Hi-Fi Class](https://www.hfc.com.pl/)
* [StagonNews](http://www.stagonnews.gr/)
* [Insurance Zebra](https://www.thezebra.com/)
* [Summoners Inn](https://www.summoners-inn.de/de/start)
* [Roots](https://roots.io/)
* [Chrdk](https://chrdk.ru/)
* [Giving Assistant](https://givingassistant.org/)
* [Just A Pinch Recipe Club](https://www.justapinch.com/)
* [am](https://www.am.com.mx/)
* [Admiral Markets](https://admiralmarkets.com/)
* [KickResume](https://www.kickresume.com/)
* [Paper Tiger](https://www.papertiger.com/)
* [Gmelius](https://gmelius.com/)
* [Dormy](https://www.dormy.se/)
* [Nabobil](https://nabobil.no/)
* [Atbox](https://atbox.io/)
* *[Add your site]* - See [Contributing section](./CONTRIBUTING.md)
## Support Lozad.js
Lozad.js is completely free and open-source. If you find it useful, you can show your support by starring it or sharing it in your social network or by simply letting me know how much you 💖 it by tweeting to [@Apoorv_Saxena](https://twitter.com/Apoorv_Saxena).
## Contribute

@@ -255,0 +223,0 @@

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