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

vanilla-lazyload

Package Overview
Dependencies
Maintainers
1
Versions
148
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vanilla-lazyload - npm Package Compare versions

Comparing version 12.5.1 to 13.0.0

dist/lazyload.esm.min.js

13

CHANGELOG.md
# CHANGELOG
## Version 13
#### 13.0.0
- Added the minified version of `dist/lazyload.esm.js` as `dist/lazyload.esm.min.js`, so now you can effortlessly use it with an ES module `import` statement when using `type="module"`
- Reduced files weight even more! `dist/lazyload.iife.min.js` now weights only 2.03 KB GZipped
- Removed the `callback_set` callback that was **deprecated** since version 11 in favour of `callback_reveal`
- Removed sourcemaps (they were probably used only by the authors, but if anyone was actually needing them, we can bring them back)
- Hidden the `_extends` function inside LazyLoad's scope (it was global before)
- Updated build tooling: removed Gulp, now using Rollup & Babel only
## Version 12

@@ -7,3 +18,3 @@

Restored IE 11 compatibility, which was broken since 12.2.0. See #414.
Restored IE 11 compatibility, which was broken since 12.2.0. See #414.
Thanks to @ninosaurus for reporting.

@@ -10,0 +21,0 @@

65

dist/lazyload.amd.js

@@ -1,6 +0,21 @@

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
define(function () { 'use strict';
define(function () {
'use strict';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var runningOnBrowser = typeof window !== "undefined";

@@ -10,2 +25,3 @@ var isBot = runningOnBrowser && !("onscroll" in window) || typeof navigator !== "undefined" && /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent);

var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
var defaultSettings = {

@@ -34,9 +50,7 @@ elements_selector: "img",

};
var getInstanceSettings = (function (customSettings) {
return _extends({}, defaultSettings, customSettings);
});
var getInstanceSettings = function getInstanceSettings(customSettings) {
return _extends({}, defaultSettings, customSettings);
};
/* Creates instance and notifies it through the window element */
var createInstance = function createInstance(classObj, options) {

@@ -68,3 +82,3 @@ var event;

function autoInitialize(classObj, options) {
function autoInitialize (classObj, options) {
if (!options) {

@@ -89,7 +103,5 @@ return;

var trueString = "true";
var getData = function getData(element, attribute) {
return element.getAttribute(dataPrefix + attribute);
};
var setData = function setData(element, attribute, value) {

@@ -105,19 +117,14 @@ var attrName = dataPrefix + attribute;

};
var resetWasProcessedData = function resetWasProcessedData(element) {
return setData(element, processedDataName, null);
};
var setWasProcessedData = function setWasProcessedData(element) {
return setData(element, processedDataName, trueString);
};
var getWasProcessedData = function getWasProcessedData(element) {
return getData(element, processedDataName) === trueString;
};
var setTimeoutData = function setTimeoutData(element, value) {
return setData(element, timeoutDataName, value);
};
var getTimeoutData = function getTimeoutData(element) {

@@ -132,3 +139,2 @@ return getData(element, timeoutDataName);

};
var purgeOneElement = function purgeOneElement(elements, elementToPurge) {

@@ -177,3 +183,2 @@ return elements.filter(function (element) {

};
var setAttributeIfValue = function setAttributeIfValue(element, attrName, value) {

@@ -186,3 +191,2 @@ if (!value) {

};
var setImageAttributes = function setImageAttributes(element, settings) {

@@ -193,3 +197,2 @@ setAttributeIfValue(element, "sizes", getData(element, settings.data_sizes));

};
var setSourcesImg = function setSourcesImg(element, settings) {

@@ -207,7 +210,5 @@ var parent = element.parentNode;

};
var setSourcesIframe = function setSourcesIframe(element, settings) {
setAttributeIfValue(element, "src", getData(element, settings.data_src));
};
var setSourcesVideo = function setSourcesVideo(element, settings) {

@@ -222,3 +223,2 @@ var sourceTags = getSourceTags(element);

};
var setSourcesBgImage = function setSourcesBgImage(element, settings) {

@@ -236,3 +236,2 @@ var srcDataValue = getData(element, settings.data_src);

};
var setSourcesFunctions = {

@@ -243,3 +242,2 @@ IMG: setSourcesImg,

};
var setSources = function setSources(element, instance) {

@@ -268,3 +266,2 @@ var settings = instance._settings;

};
var removeClass = function removeClass(element, className) {

@@ -329,3 +326,2 @@ if (supportsClassList) {

var managedTags = ["IMG", "IFRAME", "VIDEO"];
var onEnter = function onEnter(element, entry, instance) {

@@ -342,3 +338,2 @@ var settings = instance._settings;

};
var revealAndUnobserve = function revealAndUnobserve(element, instance) {

@@ -352,3 +347,2 @@ var observer = instance._observer;

};
var onExit = function onExit(element, entry, instance) {

@@ -364,3 +358,2 @@ var settings = instance._settings;

};
var cancelDelayLoad = function cancelDelayLoad(element) {

@@ -376,3 +369,2 @@ var timeoutId = getTimeoutData(element);

};
var delayLoad = function delayLoad(element, instance) {

@@ -392,3 +384,2 @@ var loadDelay = instance._settings.load_delay;

};
var revealElement = function revealElement(element, instance, force) {

@@ -409,3 +400,2 @@ var settings = instance._settings;

safeCallback(settings.callback_reveal, element, instance);
safeCallback(settings.callback_set, element, instance);
};

@@ -416,3 +406,2 @@

};
var getObserverSettings = function getObserverSettings(settings) {

@@ -424,3 +413,2 @@ return {

};
var setObserver = function setObserver(instance) {

@@ -440,7 +428,5 @@ if (!supportsIntersectionObserver) {

var nativeLazyTags = ["IMG", "IFRAME"];
var shouldUseNative = function shouldUseNative(settings) {
return settings.use_native && "loading" in HTMLImageElement.prototype;
};
var loadAllNative = function loadAllNative(instance) {

@@ -464,3 +450,2 @@ instance._elements.forEach(function (element) {

};
var getElements = function getElements(elements, settings) {

@@ -479,3 +464,2 @@ return purgeProcessedElements(nodeSetToArray(elements || queryElements(settings)));

};
var setOnlineCheck = function setOnlineCheck(instance) {

@@ -552,2 +536,3 @@ if (!runningOnBrowser) {

return LazyLoad;
});
});

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

function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}define(function(){"use strict";var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,r=t&&"classList"in document.createElement("p"),a={elements_selector:"img",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},o=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)};var s=function(t,e){return t.getAttribute("data-"+e)},i=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},c=function(t){return"true"===s(t,"was-processed")},l=function(t,e){return i(t,"ll-timeout",e)},u=function(t){return s(t,"ll-timeout")},d=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},f=function(t,e){t.loadingCount+=e,0===t._elements.length&&0===t.loadingCount&&d(t._settings.callback_finish,t)},_=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},v=function(t,e,n){n&&t.setAttribute(e,n)},g=function(t,e){v(t,"sizes",s(t,e.data_sizes)),v(t,"srcset",s(t,e.data_srcset)),v(t,"src",s(t,e.data_src))},h={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&_(n).forEach(function(t){g(t,e)});g(t,e)},IFRAME:function(t,e){v(t,"src",s(t,e.data_src))},VIDEO:function(t,e){_(t).forEach(function(t){v(t,"src",s(t,e.data_src))}),v(t,"poster",s(t,e.data_poster)),v(t,"src",s(t,e.data_src)),t.load()}},m=function(t,e){var n,r,a=e._settings,o=t.tagName,i=h[o];if(i)return i(t,a),f(e,1),void(e._elements=(n=e._elements,r=t,n.filter(function(t){return t!==r})));!function(t,e){var n=s(t,e.data_src),r=s(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),r&&(t.style.backgroundImage=r)}(t,a)},b=function(t,e){r?t.classList.add(e):t.className+=(t.className?" ":"")+e},p=function(t,e){r?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},E=function(t,e,n){t.addEventListener(e,n)},y=function(t,e,n){t.removeEventListener(e,n)},w=function(t,e,n){y(t,"load",e),y(t,"loadeddata",e),y(t,"error",n)},I=function(t,e,n){var r=n._settings,a=e?r.class_loaded:r.class_error,o=e?r.callback_loaded:r.callback_error,s=t.target;p(s,r.class_loading),b(s,a),d(o,s,n),f(n,-1)},k=function(t,e){var n=function n(a){I(a,!0,e),w(t,n,r)},r=function r(a){I(a,!1,e),w(t,n,r)};!function(t,e,n){E(t,"load",e),E(t,"loadeddata",e),E(t,"error",n)}(t,n,r)},A=["IMG","IFRAME","VIDEO"],L=function(t,e){var n=e._observer;N(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},O=function(t){var e=u(t);e&&(clearTimeout(e),l(t,null))},z=function(t,e){var n=e._settings.load_delay,r=u(t);r||(r=setTimeout(function(){L(t,e),O(t)},n),l(t,r))},N=function(t,e,n){var r=e._settings;!n&&c(t)||(A.indexOf(t.tagName)>-1&&(k(t,e),b(t,r.class_loading)),m(t,e),function(t){i(t,"was-processed","true")}(t),d(r.callback_reveal,t,e),d(r.callback_set,t,e))},x=function(t){return!!n&&(t._observer=new IntersectionObserver(function(e){e.forEach(function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var r=n._settings;d(r.callback_enter,t,e,n),r.load_delay?z(t,n):L(t,n)}(e.target,e,t):function(t,e,n){var r=n._settings;d(r.callback_exit,t,e,n),r.load_delay&&O(t)}(e.target,e,t)})},{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},C=["IMG","IFRAME"],M=function(t,e){return function(t){return t.filter(function(t){return!c(t)})}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},R=function(t){var e=t._settings;e.container.querySelectorAll("."+e.class_error).forEach(function(t){p(t,e.class_error),function(t){i(t,"was-processed",null)}(t)}),t.update()},T=function(e,n){var r;this._settings=function(t){return _extends({},a,t)}(e),this.loadingCount=0,x(this),this.update(n),r=this,t&&window.addEventListener("online",function(t){R(r)})};return T.prototype={update:function(t){var n,r=this,a=this._settings;(this._elements=M(t,a),!e&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(a)&&((n=this)._elements.forEach(function(t){-1!==C.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),N(t,n))}),this._elements=M(t,a)),this._elements.forEach(function(t){r._observer.observe(t)})):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){N(t,this,e)},loadAll:function(){var t=this;this._elements.forEach(function(e){L(e,t)})}},t&&function(t,e){if(e)if(e.length)for(var n,r=0;n=e[r];r+=1)o(t,n);else o(t,e)}(T,window.lazyLoadOptions),T});
//# sourceMappingURL=lazyload.amd.min.js.map
define((function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),r=e&&"IntersectionObserver"in window,a=e&&"classList"in document.createElement("p"),o={elements_selector:"img",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},s=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)};var i=function(t,e){return t.getAttribute("data-"+e)},c=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},l=function(t){return"true"===i(t,"was-processed")},u=function(t,e){return c(t,"ll-timeout",e)},d=function(t){return i(t,"ll-timeout")},f=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},_=function(t,e){t.loadingCount+=e,0===t._elements.length&&0===t.loadingCount&&f(t._settings.callback_finish,t)},v=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},g=function(t,e,n){n&&t.setAttribute(e,n)},h=function(t,e){g(t,"sizes",i(t,e.data_sizes)),g(t,"srcset",i(t,e.data_srcset)),g(t,"src",i(t,e.data_src))},m={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&v(n).forEach((function(t){h(t,e)}));h(t,e)},IFRAME:function(t,e){g(t,"src",i(t,e.data_src))},VIDEO:function(t,e){v(t).forEach((function(t){g(t,"src",i(t,e.data_src))})),g(t,"poster",i(t,e.data_poster)),g(t,"src",i(t,e.data_src)),t.load()}},b=function(t,e){var n,r,a=e._settings,o=t.tagName,s=m[o];if(s)return s(t,a),_(e,1),void(e._elements=(n=e._elements,r=t,n.filter((function(t){return t!==r}))));!function(t,e){var n=i(t,e.data_src),r=i(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),r&&(t.style.backgroundImage=r)}(t,a)},p=function(t,e){a?t.classList.add(e):t.className+=(t.className?" ":"")+e},E=function(t,e){a?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},y=function(t,e,n){t.addEventListener(e,n)},w=function(t,e,n){t.removeEventListener(e,n)},I=function(t,e,n){w(t,"load",e),w(t,"loadeddata",e),w(t,"error",n)},k=function(t,e,n){var r=n._settings,a=e?r.class_loaded:r.class_error,o=e?r.callback_loaded:r.callback_error,s=t.target;E(s,r.class_loading),p(s,a),f(o,s,n),_(n,-1)},A=function(t,e){var n=function n(a){k(a,!0,e),I(t,n,r)},r=function r(a){k(a,!1,e),I(t,n,r)};!function(t,e,n){y(t,"load",e),y(t,"loadeddata",e),y(t,"error",n)}(t,n,r)},L=["IMG","IFRAME","VIDEO"],O=function(t,e){var n=e._observer;C(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},z=function(t){var e=d(t);e&&(clearTimeout(e),u(t,null))},N=function(t,e){var n=e._settings.load_delay,r=d(t);r||(r=setTimeout((function(){O(t,e),z(t)}),n),u(t,r))},C=function(t,e,n){var r=e._settings;!n&&l(t)||(L.indexOf(t.tagName)>-1&&(A(t,e),p(t,r.class_loading)),b(t,e),function(t){c(t,"was-processed","true")}(t),f(r.callback_reveal,t,e))},M=function(t){return!!r&&(t._observer=new IntersectionObserver((function(e){e.forEach((function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var r=n._settings;f(r.callback_enter,t,e,n),r.load_delay?N(t,n):O(t,n)}(e.target,e,t):function(t,e,n){var r=n._settings;f(r.callback_exit,t,e,n),r.load_delay&&z(t)}(e.target,e,t)}))}),{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},R=["IMG","IFRAME"],x=function(t,e){return function(t){return t.filter((function(t){return!l(t)}))}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},T=function(t){var e=t._settings;e.container.querySelectorAll("."+e.class_error).forEach((function(t){E(t,e.class_error),function(t){c(t,"was-processed",null)}(t)})),t.update()},F=function(n,r){var a;this._settings=function(e){return t({},o,e)}(n),this.loadingCount=0,M(this),this.update(r),a=this,e&&window.addEventListener("online",(function(t){T(a)}))};return F.prototype={update:function(t){var e,r=this,a=this._settings;(this._elements=x(t,a),!n&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(a)&&((e=this)._elements.forEach((function(t){-1!==R.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),C(t,e))})),this._elements=x(t,a)),this._elements.forEach((function(t){r._observer.observe(t)}))):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach((function(e){t._observer.unobserve(e)})),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){C(t,this,e)},loadAll:function(){var t=this;this._elements.forEach((function(e){O(e,t)}))}},e&&function(t,e){if(e)if(e.length)for(var n,r=0;n=e[r];r+=1)s(t,n);else s(t,e)}(F,window.lazyLoadOptions),F}));

@@ -369,3 +369,2 @@ const runningOnBrowser = typeof window !== "undefined";

safeCallback(settings.callback_reveal, element, instance);
safeCallback(settings.callback_set, element, instance);
};

@@ -372,0 +371,0 @@

@@ -1,6 +0,22 @@

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
var LazyLoad = function () {
var LazyLoad = (function () {
'use strict';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var runningOnBrowser = typeof window !== "undefined";

@@ -10,2 +26,3 @@ var isBot = runningOnBrowser && !("onscroll" in window) || typeof navigator !== "undefined" && /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent);

var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
var defaultSettings = {

@@ -34,9 +51,7 @@ elements_selector: "img",

};
var getInstanceSettings = (function (customSettings) {
return _extends({}, defaultSettings, customSettings);
});
var getInstanceSettings = function getInstanceSettings(customSettings) {
return _extends({}, defaultSettings, customSettings);
};
/* Creates instance and notifies it through the window element */
var createInstance = function createInstance(classObj, options) {

@@ -68,3 +83,3 @@ var event;

function autoInitialize(classObj, options) {
function autoInitialize (classObj, options) {
if (!options) {

@@ -89,7 +104,5 @@ return;

var trueString = "true";
var getData = function getData(element, attribute) {
return element.getAttribute(dataPrefix + attribute);
};
var setData = function setData(element, attribute, value) {

@@ -105,19 +118,14 @@ var attrName = dataPrefix + attribute;

};
var resetWasProcessedData = function resetWasProcessedData(element) {
return setData(element, processedDataName, null);
};
var setWasProcessedData = function setWasProcessedData(element) {
return setData(element, processedDataName, trueString);
};
var getWasProcessedData = function getWasProcessedData(element) {
return getData(element, processedDataName) === trueString;
};
var setTimeoutData = function setTimeoutData(element, value) {
return setData(element, timeoutDataName, value);
};
var getTimeoutData = function getTimeoutData(element) {

@@ -132,3 +140,2 @@ return getData(element, timeoutDataName);

};
var purgeOneElement = function purgeOneElement(elements, elementToPurge) {

@@ -177,3 +184,2 @@ return elements.filter(function (element) {

};
var setAttributeIfValue = function setAttributeIfValue(element, attrName, value) {

@@ -186,3 +192,2 @@ if (!value) {

};
var setImageAttributes = function setImageAttributes(element, settings) {

@@ -193,3 +198,2 @@ setAttributeIfValue(element, "sizes", getData(element, settings.data_sizes));

};
var setSourcesImg = function setSourcesImg(element, settings) {

@@ -207,7 +211,5 @@ var parent = element.parentNode;

};
var setSourcesIframe = function setSourcesIframe(element, settings) {
setAttributeIfValue(element, "src", getData(element, settings.data_src));
};
var setSourcesVideo = function setSourcesVideo(element, settings) {

@@ -222,3 +224,2 @@ var sourceTags = getSourceTags(element);

};
var setSourcesBgImage = function setSourcesBgImage(element, settings) {

@@ -236,3 +237,2 @@ var srcDataValue = getData(element, settings.data_src);

};
var setSourcesFunctions = {

@@ -243,3 +243,2 @@ IMG: setSourcesImg,

};
var setSources = function setSources(element, instance) {

@@ -268,3 +267,2 @@ var settings = instance._settings;

};
var removeClass = function removeClass(element, className) {

@@ -329,3 +327,2 @@ if (supportsClassList) {

var managedTags = ["IMG", "IFRAME", "VIDEO"];
var onEnter = function onEnter(element, entry, instance) {

@@ -342,3 +339,2 @@ var settings = instance._settings;

};
var revealAndUnobserve = function revealAndUnobserve(element, instance) {

@@ -352,3 +348,2 @@ var observer = instance._observer;

};
var onExit = function onExit(element, entry, instance) {

@@ -364,3 +359,2 @@ var settings = instance._settings;

};
var cancelDelayLoad = function cancelDelayLoad(element) {

@@ -376,3 +370,2 @@ var timeoutId = getTimeoutData(element);

};
var delayLoad = function delayLoad(element, instance) {

@@ -392,3 +385,2 @@ var loadDelay = instance._settings.load_delay;

};
var revealElement = function revealElement(element, instance, force) {

@@ -409,3 +401,2 @@ var settings = instance._settings;

safeCallback(settings.callback_reveal, element, instance);
safeCallback(settings.callback_set, element, instance);
};

@@ -416,3 +407,2 @@

};
var getObserverSettings = function getObserverSettings(settings) {

@@ -424,3 +414,2 @@ return {

};
var setObserver = function setObserver(instance) {

@@ -440,7 +429,5 @@ if (!supportsIntersectionObserver) {

var nativeLazyTags = ["IMG", "IFRAME"];
var shouldUseNative = function shouldUseNative(settings) {
return settings.use_native && "loading" in HTMLImageElement.prototype;
};
var loadAllNative = function loadAllNative(instance) {

@@ -464,3 +451,2 @@ instance._elements.forEach(function (element) {

};
var getElements = function getElements(elements, settings) {

@@ -479,3 +465,2 @@ return purgeProcessedElements(nodeSetToArray(elements || queryElements(settings)));

};
var setOnlineCheck = function setOnlineCheck(instance) {

@@ -552,2 +537,3 @@ if (!runningOnBrowser) {

return LazyLoad;
}();
}());

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

function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var a in n)Object.prototype.hasOwnProperty.call(n,a)&&(t[a]=n[a])}return t}).apply(this,arguments)}var LazyLoad=function(){"use strict";var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,a=t&&"classList"in document.createElement("p"),r={elements_selector:"img",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},o=function(t,e){var n,a=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:a}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:a})}window.dispatchEvent(n)};var s=function(t,e){return t.getAttribute("data-"+e)},i=function(t,e,n){var a="data-"+e;null!==n?t.setAttribute(a,n):t.removeAttribute(a)},c=function(t){return"true"===s(t,"was-processed")},l=function(t,e){return i(t,"ll-timeout",e)},u=function(t){return s(t,"ll-timeout")},d=function(t,e,n,a){t&&(void 0===a?void 0===n?t(e):t(e,n):t(e,n,a))},f=function(t,e){t.loadingCount+=e,0===t._elements.length&&0===t.loadingCount&&d(t._settings.callback_finish,t)},_=function(t){for(var e,n=[],a=0;e=t.children[a];a+=1)"SOURCE"===e.tagName&&n.push(e);return n},v=function(t,e,n){n&&t.setAttribute(e,n)},g=function(t,e){v(t,"sizes",s(t,e.data_sizes)),v(t,"srcset",s(t,e.data_srcset)),v(t,"src",s(t,e.data_src))},h={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&_(n).forEach(function(t){g(t,e)});g(t,e)},IFRAME:function(t,e){v(t,"src",s(t,e.data_src))},VIDEO:function(t,e){_(t).forEach(function(t){v(t,"src",s(t,e.data_src))}),v(t,"poster",s(t,e.data_poster)),v(t,"src",s(t,e.data_src)),t.load()}},m=function(t,e){var n,a,r=e._settings,o=t.tagName,i=h[o];if(i)return i(t,r),f(e,1),void(e._elements=(n=e._elements,a=t,n.filter(function(t){return t!==a})));!function(t,e){var n=s(t,e.data_src),a=s(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),a&&(t.style.backgroundImage=a)}(t,r)},b=function(t,e){a?t.classList.add(e):t.className+=(t.className?" ":"")+e},p=function(t,e){a?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},E=function(t,e,n){t.addEventListener(e,n)},y=function(t,e,n){t.removeEventListener(e,n)},w=function(t,e,n){y(t,"load",e),y(t,"loadeddata",e),y(t,"error",n)},I=function(t,e,n){var a=n._settings,r=e?a.class_loaded:a.class_error,o=e?a.callback_loaded:a.callback_error,s=t.target;p(s,a.class_loading),b(s,r),d(o,s,n),f(n,-1)},k=function(t,e){var n=function n(r){I(r,!0,e),w(t,n,a)},a=function a(r){I(r,!1,e),w(t,n,a)};!function(t,e,n){E(t,"load",e),E(t,"loadeddata",e),E(t,"error",n)}(t,n,a)},A=["IMG","IFRAME","VIDEO"],L=function(t,e){var n=e._observer;N(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},z=function(t){var e=u(t);e&&(clearTimeout(e),l(t,null))},O=function(t,e){var n=e._settings.load_delay,a=u(t);a||(a=setTimeout(function(){L(t,e),z(t)},n),l(t,a))},N=function(t,e,n){var a=e._settings;!n&&c(t)||(A.indexOf(t.tagName)>-1&&(k(t,e),b(t,a.class_loading)),m(t,e),function(t){i(t,"was-processed","true")}(t),d(a.callback_reveal,t,e),d(a.callback_set,t,e))},x=function(t){return!!n&&(t._observer=new IntersectionObserver(function(e){e.forEach(function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var a=n._settings;d(a.callback_enter,t,e,n),a.load_delay?O(t,n):L(t,n)}(e.target,e,t):function(t,e,n){var a=n._settings;d(a.callback_exit,t,e,n),a.load_delay&&z(t)}(e.target,e,t)})},{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},C=["IMG","IFRAME"],M=function(t,e){return function(t){return t.filter(function(t){return!c(t)})}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},R=function(t){var e=t._settings;e.container.querySelectorAll("."+e.class_error).forEach(function(t){p(t,e.class_error),function(t){i(t,"was-processed",null)}(t)}),t.update()},T=function(e,n){var a;this._settings=function(t){return _extends({},r,t)}(e),this.loadingCount=0,x(this),this.update(n),a=this,t&&window.addEventListener("online",function(t){R(a)})};return T.prototype={update:function(t){var n,a=this,r=this._settings;(this._elements=M(t,r),!e&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(r)&&((n=this)._elements.forEach(function(t){-1!==C.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),N(t,n))}),this._elements=M(t,r)),this._elements.forEach(function(t){a._observer.observe(t)})):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){N(t,this,e)},loadAll:function(){var t=this;this._elements.forEach(function(e){L(e,t)})}},t&&function(t,e){if(e)if(e.length)for(var n,a=0;n=e[a];a+=1)o(t,n);else o(t,e)}(T,window.lazyLoadOptions),T}();
//# sourceMappingURL=lazyload.iife.min.js.map
var LazyLoad=function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),r=e&&"IntersectionObserver"in window,a=e&&"classList"in document.createElement("p"),o={elements_selector:"img",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},s=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)};var i=function(t,e){return t.getAttribute("data-"+e)},c=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},l=function(t){return"true"===i(t,"was-processed")},u=function(t,e){return c(t,"ll-timeout",e)},d=function(t){return i(t,"ll-timeout")},f=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},_=function(t,e){t.loadingCount+=e,0===t._elements.length&&0===t.loadingCount&&f(t._settings.callback_finish,t)},v=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},g=function(t,e,n){n&&t.setAttribute(e,n)},h=function(t,e){g(t,"sizes",i(t,e.data_sizes)),g(t,"srcset",i(t,e.data_srcset)),g(t,"src",i(t,e.data_src))},m={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&v(n).forEach((function(t){h(t,e)}));h(t,e)},IFRAME:function(t,e){g(t,"src",i(t,e.data_src))},VIDEO:function(t,e){v(t).forEach((function(t){g(t,"src",i(t,e.data_src))})),g(t,"poster",i(t,e.data_poster)),g(t,"src",i(t,e.data_src)),t.load()}},b=function(t,e){var n,r,a=e._settings,o=t.tagName,s=m[o];if(s)return s(t,a),_(e,1),void(e._elements=(n=e._elements,r=t,n.filter((function(t){return t!==r}))));!function(t,e){var n=i(t,e.data_src),r=i(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),r&&(t.style.backgroundImage=r)}(t,a)},p=function(t,e){a?t.classList.add(e):t.className+=(t.className?" ":"")+e},E=function(t,e){a?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},y=function(t,e,n){t.addEventListener(e,n)},w=function(t,e,n){t.removeEventListener(e,n)},I=function(t,e,n){w(t,"load",e),w(t,"loadeddata",e),w(t,"error",n)},k=function(t,e,n){var r=n._settings,a=e?r.class_loaded:r.class_error,o=e?r.callback_loaded:r.callback_error,s=t.target;E(s,r.class_loading),p(s,a),f(o,s,n),_(n,-1)},A=function(t,e){var n=function n(a){k(a,!0,e),I(t,n,r)},r=function r(a){k(a,!1,e),I(t,n,r)};!function(t,e,n){y(t,"load",e),y(t,"loadeddata",e),y(t,"error",n)}(t,n,r)},L=["IMG","IFRAME","VIDEO"],z=function(t,e){var n=e._observer;C(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},O=function(t){var e=d(t);e&&(clearTimeout(e),u(t,null))},N=function(t,e){var n=e._settings.load_delay,r=d(t);r||(r=setTimeout((function(){z(t,e),O(t)}),n),u(t,r))},C=function(t,e,n){var r=e._settings;!n&&l(t)||(L.indexOf(t.tagName)>-1&&(A(t,e),p(t,r.class_loading)),b(t,e),function(t){c(t,"was-processed","true")}(t),f(r.callback_reveal,t,e))},M=function(t){return!!r&&(t._observer=new IntersectionObserver((function(e){e.forEach((function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var r=n._settings;f(r.callback_enter,t,e,n),r.load_delay?N(t,n):z(t,n)}(e.target,e,t):function(t,e,n){var r=n._settings;f(r.callback_exit,t,e,n),r.load_delay&&O(t)}(e.target,e,t)}))}),{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},R=["IMG","IFRAME"],x=function(t,e){return function(t){return t.filter((function(t){return!l(t)}))}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},T=function(t){var e=t._settings;e.container.querySelectorAll("."+e.class_error).forEach((function(t){E(t,e.class_error),function(t){c(t,"was-processed",null)}(t)})),t.update()},F=function(n,r){var a;this._settings=function(e){return t({},o,e)}(n),this.loadingCount=0,M(this),this.update(r),a=this,e&&window.addEventListener("online",(function(t){T(a)}))};return F.prototype={update:function(t){var e,r=this,a=this._settings;(this._elements=x(t,a),!n&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(a)&&((e=this)._elements.forEach((function(t){-1!==R.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),C(t,e))})),this._elements=x(t,a)),this._elements.forEach((function(t){r._observer.observe(t)}))):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach((function(e){t._observer.unobserve(e)})),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){C(t,this,e)},loadAll:function(){var t=this;this._elements.forEach((function(e){z(e,t)}))}},e&&function(t,e){if(e)if(e.length)for(var n,r=0;n=e[r];r+=1)s(t,n);else s(t,e)}(F,window.lazyLoadOptions),F}();

@@ -1,10 +0,25 @@

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.LazyLoad = factory());
}(this, (function () { 'use strict';
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
(function (global, factory) {
(typeof exports === "undefined" ? "undefined" : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.LazyLoad = factory());
})(this, function () {
'use strict';
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
var runningOnBrowser = typeof window !== "undefined";

@@ -14,2 +29,3 @@ var isBot = runningOnBrowser && !("onscroll" in window) || typeof navigator !== "undefined" && /(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent);

var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
var defaultSettings = {

@@ -38,9 +54,7 @@ elements_selector: "img",

};
var getInstanceSettings = (function (customSettings) {
return _extends({}, defaultSettings, customSettings);
});
var getInstanceSettings = function getInstanceSettings(customSettings) {
return _extends({}, defaultSettings, customSettings);
};
/* Creates instance and notifies it through the window element */
var createInstance = function createInstance(classObj, options) {

@@ -72,3 +86,3 @@ var event;

function autoInitialize(classObj, options) {
function autoInitialize (classObj, options) {
if (!options) {

@@ -93,7 +107,5 @@ return;

var trueString = "true";
var getData = function getData(element, attribute) {
return element.getAttribute(dataPrefix + attribute);
};
var setData = function setData(element, attribute, value) {

@@ -109,19 +121,14 @@ var attrName = dataPrefix + attribute;

};
var resetWasProcessedData = function resetWasProcessedData(element) {
return setData(element, processedDataName, null);
};
var setWasProcessedData = function setWasProcessedData(element) {
return setData(element, processedDataName, trueString);
};
var getWasProcessedData = function getWasProcessedData(element) {
return getData(element, processedDataName) === trueString;
};
var setTimeoutData = function setTimeoutData(element, value) {
return setData(element, timeoutDataName, value);
};
var getTimeoutData = function getTimeoutData(element) {

@@ -136,3 +143,2 @@ return getData(element, timeoutDataName);

};
var purgeOneElement = function purgeOneElement(elements, elementToPurge) {

@@ -181,3 +187,2 @@ return elements.filter(function (element) {

};
var setAttributeIfValue = function setAttributeIfValue(element, attrName, value) {

@@ -190,3 +195,2 @@ if (!value) {

};
var setImageAttributes = function setImageAttributes(element, settings) {

@@ -197,3 +201,2 @@ setAttributeIfValue(element, "sizes", getData(element, settings.data_sizes));

};
var setSourcesImg = function setSourcesImg(element, settings) {

@@ -211,7 +214,5 @@ var parent = element.parentNode;

};
var setSourcesIframe = function setSourcesIframe(element, settings) {
setAttributeIfValue(element, "src", getData(element, settings.data_src));
};
var setSourcesVideo = function setSourcesVideo(element, settings) {

@@ -226,3 +227,2 @@ var sourceTags = getSourceTags(element);

};
var setSourcesBgImage = function setSourcesBgImage(element, settings) {

@@ -240,3 +240,2 @@ var srcDataValue = getData(element, settings.data_src);

};
var setSourcesFunctions = {

@@ -247,3 +246,2 @@ IMG: setSourcesImg,

};
var setSources = function setSources(element, instance) {

@@ -272,3 +270,2 @@ var settings = instance._settings;

};
var removeClass = function removeClass(element, className) {

@@ -333,3 +330,2 @@ if (supportsClassList) {

var managedTags = ["IMG", "IFRAME", "VIDEO"];
var onEnter = function onEnter(element, entry, instance) {

@@ -346,3 +342,2 @@ var settings = instance._settings;

};
var revealAndUnobserve = function revealAndUnobserve(element, instance) {

@@ -356,3 +351,2 @@ var observer = instance._observer;

};
var onExit = function onExit(element, entry, instance) {

@@ -368,3 +362,2 @@ var settings = instance._settings;

};
var cancelDelayLoad = function cancelDelayLoad(element) {

@@ -380,3 +373,2 @@ var timeoutId = getTimeoutData(element);

};
var delayLoad = function delayLoad(element, instance) {

@@ -396,3 +388,2 @@ var loadDelay = instance._settings.load_delay;

};
var revealElement = function revealElement(element, instance, force) {

@@ -413,3 +404,2 @@ var settings = instance._settings;

safeCallback(settings.callback_reveal, element, instance);
safeCallback(settings.callback_set, element, instance);
};

@@ -420,3 +410,2 @@

};
var getObserverSettings = function getObserverSettings(settings) {

@@ -428,3 +417,2 @@ return {

};
var setObserver = function setObserver(instance) {

@@ -444,7 +432,5 @@ if (!supportsIntersectionObserver) {

var nativeLazyTags = ["IMG", "IFRAME"];
var shouldUseNative = function shouldUseNative(settings) {
return settings.use_native && "loading" in HTMLImageElement.prototype;
};
var loadAllNative = function loadAllNative(instance) {

@@ -468,3 +454,2 @@ instance._elements.forEach(function (element) {

};
var getElements = function getElements(elements, settings) {

@@ -483,3 +468,2 @@ return purgeProcessedElements(nodeSetToArray(elements || queryElements(settings)));

};
var setOnlineCheck = function setOnlineCheck(instance) {

@@ -556,2 +540,3 @@ if (!runningOnBrowser) {

return LazyLoad;
});
})));

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

function _extends(){return(_extends=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t}).apply(this,arguments)}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}!function(t,e){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).LazyLoad=e()}(this,function(){"use strict";var t="undefined"!=typeof window,e=t&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),n=t&&"IntersectionObserver"in window,o=t&&"classList"in document.createElement("p"),r={elements_selector:"img",container:e||t?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},a=function(t,e){var n,o=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)};var s=function(t,e){return t.getAttribute("data-"+e)},i=function(t,e,n){var o="data-"+e;null!==n?t.setAttribute(o,n):t.removeAttribute(o)},c=function(t){return"true"===s(t,"was-processed")},l=function(t,e){return i(t,"ll-timeout",e)},u=function(t){return s(t,"ll-timeout")},d=function(t,e,n,o){t&&(void 0===o?void 0===n?t(e):t(e,n):t(e,n,o))},f=function(t,e){t.loadingCount+=e,0===t._elements.length&&0===t.loadingCount&&d(t._settings.callback_finish,t)},_=function(t){for(var e,n=[],o=0;e=t.children[o];o+=1)"SOURCE"===e.tagName&&n.push(e);return n},v=function(t,e,n){n&&t.setAttribute(e,n)},g=function(t,e){v(t,"sizes",s(t,e.data_sizes)),v(t,"srcset",s(t,e.data_srcset)),v(t,"src",s(t,e.data_src))},m={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&_(n).forEach(function(t){g(t,e)});g(t,e)},IFRAME:function(t,e){v(t,"src",s(t,e.data_src))},VIDEO:function(t,e){_(t).forEach(function(t){v(t,"src",s(t,e.data_src))}),v(t,"poster",s(t,e.data_poster)),v(t,"src",s(t,e.data_src)),t.load()}},h=function(t,e){var n,o,r=e._settings,a=t.tagName,i=m[a];if(i)return i(t,r),f(e,1),void(e._elements=(n=e._elements,o=t,n.filter(function(t){return t!==o})));!function(t,e){var n=s(t,e.data_src),o=s(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),o&&(t.style.backgroundImage=o)}(t,r)},p=function(t,e){o?t.classList.add(e):t.className+=(t.className?" ":"")+e},b=function(t,e){o?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},y=function(t,e,n){t.addEventListener(e,n)},E=function(t,e,n){t.removeEventListener(e,n)},w=function(t,e,n){E(t,"load",e),E(t,"loadeddata",e),E(t,"error",n)},I=function(t,e,n){var o=n._settings,r=e?o.class_loaded:o.class_error,a=e?o.callback_loaded:o.callback_error,s=t.target;b(s,o.class_loading),p(s,r),d(a,s,n),f(n,-1)},k=function(t,e){var n=function n(r){I(r,!0,e),w(t,n,o)},o=function o(r){I(r,!1,e),w(t,n,o)};!function(t,e,n){y(t,"load",e),y(t,"loadeddata",e),y(t,"error",n)}(t,n,o)},A=["IMG","IFRAME","VIDEO"],L=function(t,e){var n=e._observer;O(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},x=function(t){var e=u(t);e&&(clearTimeout(e),l(t,null))},z=function(t,e){var n=e._settings.load_delay,o=u(t);o||(o=setTimeout(function(){L(t,e),x(t)},n),l(t,o))},O=function(t,e,n){var o=e._settings;!n&&c(t)||(A.indexOf(t.tagName)>-1&&(k(t,e),p(t,o.class_loading)),h(t,e),function(t){i(t,"was-processed","true")}(t),d(o.callback_reveal,t,e),d(o.callback_set,t,e))},N=function(t){return!!n&&(t._observer=new IntersectionObserver(function(e){e.forEach(function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var o=n._settings;d(o.callback_enter,t,e,n),o.load_delay?z(t,n):L(t,n)}(e.target,e,t):function(t,e,n){var o=n._settings;d(o.callback_exit,t,e,n),o.load_delay&&x(t)}(e.target,e,t)})},{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},C=["IMG","IFRAME"],M=function(t,e){return function(t){return t.filter(function(t){return!c(t)})}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},S=function(t){var e=t._settings;e.container.querySelectorAll("."+e.class_error).forEach(function(t){b(t,e.class_error),function(t){i(t,"was-processed",null)}(t)}),t.update()},R=function(e,n){var o;this._settings=function(t){return _extends({},r,t)}(e),this.loadingCount=0,N(this),this.update(n),o=this,t&&window.addEventListener("online",function(t){S(o)})};return R.prototype={update:function(t){var n,o=this,r=this._settings;(this._elements=M(t,r),!e&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(r)&&((n=this)._elements.forEach(function(t){-1!==C.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),O(t,n))}),this._elements=M(t,r)),this._elements.forEach(function(t){o._observer.observe(t)})):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){O(t,this,e)},loadAll:function(){var t=this;this._elements.forEach(function(e){L(e,t)})}},t&&function(t,e){if(e)if(e.length)for(var n,o=0;n=e[o];o+=1)a(t,n);else a(t,e)}(R,window.lazyLoadOptions),R});
//# sourceMappingURL=lazyload.min.js.map
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).LazyLoad=e()}(this,(function(){"use strict";function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}var e="undefined"!=typeof window,n=e&&!("onscroll"in window)||"undefined"!=typeof navigator&&/(gle|ing|ro)bot|crawl|spider/i.test(navigator.userAgent),r=e&&"IntersectionObserver"in window,a=e&&"classList"in document.createElement("p"),o={elements_selector:"img",container:n||e?document:null,threshold:300,thresholds:null,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",data_bg:"bg",data_poster:"poster",class_loading:"loading",class_loaded:"loaded",class_error:"error",load_delay:0,auto_unobserve:!0,callback_enter:null,callback_exit:null,callback_reveal:null,callback_loaded:null,callback_error:null,callback_finish:null,use_native:!1},s=function(t,e){var n,r=new t(e);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(t){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)};var i=function(t,e){return t.getAttribute("data-"+e)},c=function(t,e,n){var r="data-"+e;null!==n?t.setAttribute(r,n):t.removeAttribute(r)},l=function(t){return"true"===i(t,"was-processed")},u=function(t,e){return c(t,"ll-timeout",e)},d=function(t){return i(t,"ll-timeout")},f=function(t,e,n,r){t&&(void 0===r?void 0===n?t(e):t(e,n):t(e,n,r))},_=function(t,e){t.loadingCount+=e,0===t._elements.length&&0===t.loadingCount&&f(t._settings.callback_finish,t)},v=function(t){for(var e,n=[],r=0;e=t.children[r];r+=1)"SOURCE"===e.tagName&&n.push(e);return n},g=function(t,e,n){n&&t.setAttribute(e,n)},h=function(t,e){g(t,"sizes",i(t,e.data_sizes)),g(t,"srcset",i(t,e.data_srcset)),g(t,"src",i(t,e.data_src))},m={IMG:function(t,e){var n=t.parentNode;n&&"PICTURE"===n.tagName&&v(n).forEach((function(t){h(t,e)}));h(t,e)},IFRAME:function(t,e){g(t,"src",i(t,e.data_src))},VIDEO:function(t,e){v(t).forEach((function(t){g(t,"src",i(t,e.data_src))})),g(t,"poster",i(t,e.data_poster)),g(t,"src",i(t,e.data_src)),t.load()}},b=function(t,e){var n,r,a=e._settings,o=t.tagName,s=m[o];if(s)return s(t,a),_(e,1),void(e._elements=(n=e._elements,r=t,n.filter((function(t){return t!==r}))));!function(t,e){var n=i(t,e.data_src),r=i(t,e.data_bg);n&&(t.style.backgroundImage='url("'.concat(n,'")')),r&&(t.style.backgroundImage=r)}(t,a)},p=function(t,e){a?t.classList.add(e):t.className+=(t.className?" ":"")+e},y=function(t,e){a?t.classList.remove(e):t.className=t.className.replace(new RegExp("(^|\\s+)"+e+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},E=function(t,e,n){t.addEventListener(e,n)},w=function(t,e,n){t.removeEventListener(e,n)},I=function(t,e,n){w(t,"load",e),w(t,"loadeddata",e),w(t,"error",n)},k=function(t,e,n){var r=n._settings,a=e?r.class_loaded:r.class_error,o=e?r.callback_loaded:r.callback_error,s=t.target;y(s,r.class_loading),p(s,a),f(o,s,n),_(n,-1)},A=function(t,e){var n=function n(a){k(a,!0,e),I(t,n,r)},r=function r(a){k(a,!1,e),I(t,n,r)};!function(t,e,n){E(t,"load",e),E(t,"loadeddata",e),E(t,"error",n)}(t,n,r)},L=["IMG","IFRAME","VIDEO"],z=function(t,e){var n=e._observer;x(t,e),n&&e._settings.auto_unobserve&&n.unobserve(t)},O=function(t){var e=d(t);e&&(clearTimeout(e),u(t,null))},N=function(t,e){var n=e._settings.load_delay,r=d(t);r||(r=setTimeout((function(){z(t,e),O(t)}),n),u(t,r))},x=function(t,e,n){var r=e._settings;!n&&l(t)||(L.indexOf(t.tagName)>-1&&(A(t,e),p(t,r.class_loading)),b(t,e),function(t){c(t,"was-processed","true")}(t),f(r.callback_reveal,t,e))},C=function(t){return!!r&&(t._observer=new IntersectionObserver((function(e){e.forEach((function(e){return function(t){return t.isIntersecting||t.intersectionRatio>0}(e)?function(t,e,n){var r=n._settings;f(r.callback_enter,t,e,n),r.load_delay?N(t,n):z(t,n)}(e.target,e,t):function(t,e,n){var r=n._settings;f(r.callback_exit,t,e,n),r.load_delay&&O(t)}(e.target,e,t)}))}),{root:(e=t._settings).container===document?null:e.container,rootMargin:e.thresholds||e.threshold+"px"}),!0);var e},M=["IMG","IFRAME"],R=function(t,e){return function(t){return t.filter((function(t){return!l(t)}))}((n=t||function(t){return t.container.querySelectorAll(t.elements_selector)}(e),Array.prototype.slice.call(n)));var n},T=function(t){var e=t._settings;e.container.querySelectorAll("."+e.class_error).forEach((function(t){y(t,e.class_error),function(t){c(t,"was-processed",null)}(t)})),t.update()},j=function(n,r){var a;this._settings=function(e){return t({},o,e)}(n),this.loadingCount=0,C(this),this.update(r),a=this,e&&window.addEventListener("online",(function(t){T(a)}))};return j.prototype={update:function(t){var e,r=this,a=this._settings;(this._elements=R(t,a),!n&&this._observer)?(function(t){return t.use_native&&"loading"in HTMLImageElement.prototype}(a)&&((e=this)._elements.forEach((function(t){-1!==M.indexOf(t.tagName)&&(t.setAttribute("loading","lazy"),x(t,e))})),this._elements=R(t,a)),this._elements.forEach((function(t){r._observer.observe(t)}))):this.loadAll()},destroy:function(){var t=this;this._observer&&(this._elements.forEach((function(e){t._observer.unobserve(e)})),this._observer=null),this._elements=null,this._settings=null},load:function(t,e){x(t,this,e)},loadAll:function(){var t=this;this._elements.forEach((function(e){z(e,t)}))}},e&&function(t,e){if(e)if(e.length)for(var n,r=0;n=e[r];r+=1)s(t,n);else s(t,e)}(j,window.lazyLoadOptions),j}));
{
"name": "vanilla-lazyload",
"version": "12.5.1",
"version": "13.0.0",
"description": "A fast, lightweight script to load images as they enter the viewport. SEO friendly, it supports responsive images (both srcset + sizes and picture) and progressive JPEG",

@@ -11,19 +11,14 @@ "main": "dist/lazyload.min.js",

"devDependencies": {
"@babel/core": "^7.6.4",
"@babel/core": "^7.8.6",
"@babel/plugin-transform-object-assign": "^7.8.3",
"@babel/preset-env": "^7.6.3",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^24.9.0",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-eslint": "^5.0.0",
"gulp-rename": "^1.4.0",
"gulp-rollup": "^2.17.0",
"gulp-sourcemaps": "^2.6.5",
"gulp-uglify-es": "^1.0.4",
"jest": "^24.9.0"
"@babel/preset-env": "^7.8.6",
"@rollup/plugin-node-resolve": "^7.1.1",
"jest": "^25.1.0",
"rollup": "^1.32.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-terser": "^5.2.0"
},
"scripts": {
"build": "gulp",
"dev": "gulp watch",
"build": "rollup -c",
"dev": "rollup -c --watch",
"test": "jest"

@@ -58,3 +53,3 @@ },

"email": "andrea.verlicchi@gmail.com",
"url": "http://andreaverlicchi.eu"
"url": "https://www.andreaverlicchi.eu"
},

@@ -61,0 +56,0 @@ "license": "MIT",

@@ -116,3 +116,3 @@ LazyLoad is a fast, lightweight and flexible script that **speeds up your web application** by loading your content images, videos and iframes only **as they enter the viewport**. It's written in plain "vanilla" JavaScript, it leverages the [IntersectionObserver](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API) API, it works with [responsive images](https://alistapart.com/article/responsive-images-in-practice) and it supports native lazy loading. See [notable features](#-notable-features) for more.

The latest, recommended version of LazyLoad is **12.5.1**.
The latest, recommended version of LazyLoad is **13.0.0**.

@@ -132,3 +132,3 @@ ### To polyfill or not to polyfill IntersectionObserver?

```html
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@12.5.1/dist/lazyload.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@13.0.0/dist/lazyload.min.js"></script>
```

@@ -140,3 +140,3 @@

<script src="https://cdn.jsdelivr.net/npm/intersection-observer@0.7.0/intersection-observer.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@12.5.1/dist/lazyload.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@13.0.0/dist/lazyload.min.js"></script>
```

@@ -174,4 +174,4 @@

```js
var lazyLoadAmdUrl = "https://cdn.jsdelivr.net/npm/vanilla-lazyload@12.5.1/dist/lazyload.amd.min.js";
var polyfillAmdUrl = "https://cdn.jsdelivr.net/npm/intersection-observer-amd@2.1.0/intersection-observer-amd.js";
var lazyLoadAmdUrl = "https://cdn.jsdelivr.net/npm/vanilla-lazyload@13.0.0/dist/lazyload.amd.min.js";
var polyfillAmdUrl = "https://cdn.jsdelivr.net/npm/intersection-observer-amd@2.0.1/intersection-observer-amd.js";

@@ -221,3 +221,3 @@ /// Dynamically define the dependencies

async
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@12.5.1/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@13.0.0/dist/lazyload.min.js"
></script>

@@ -255,3 +255,3 @@ ```

async
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@12.5.1/dist/lazyload.min.js"
src="https://cdn.jsdelivr.net/npm/vanilla-lazyload@13.0.0/dist/lazyload.min.js"
></script>

@@ -645,3 +645,2 @@ ```

| `callback_reveal` | A callback function which is called whenever an element starts loading. Arguments: DOM element, lazyload instance. | `null` | `(el)=>{console.log("Loading", el)}` |
| `callback_set` | **Deprecated from version 11** &rarr; It still works, but please update your code to use `callback_reveal` instead. | `null` | `(el)=>{console.log("Loading", el)}` |
| `callback_loaded` | A callback function which is called whenever an element finishes loading. Note that, in version older than 11.0.0, this option went under the name `callback_load`. Arguments: DOM element, lazyload instance. | `null` | `(el)=>{console.log("Loaded", el)}` |

@@ -648,0 +647,0 @@ | `callback_error` | A callback function which is called whenever an element triggers an error. Arguments: DOM element, lazyload instance. | `null` | `(el)=>{console.log("Error", el)}` |

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