vanilla-lazyload
Advanced tools
Comparing version 10.11.1 to 10.12.0
@@ -5,2 +5,6 @@ # CHANGELOG | ||
#### 10.12.0 | ||
SEO! Expanded SEO-friendliness to more crawlers, Bingbot included. | ||
#### 10.11.1 | ||
@@ -124,2 +128,6 @@ | ||
#### 8.12.0 | ||
SEO! Expanded SEO-friendliness to more crawlers, Bingbot included. | ||
#### 8.11.0 | ||
@@ -126,0 +134,0 @@ |
@@ -50,16 +50,15 @@ (function (global, factory) { | ||
/* Creates instance and notifies it through the window element */ | ||
const createInstance = function (classObj, options) { | ||
var event; | ||
let eventString = "LazyLoad::Initialized"; | ||
let instance = new classObj(options); | ||
try { | ||
// Works in modern browsers | ||
event = new CustomEvent(eventString, { detail: { instance } }); | ||
} | ||
catch(err) { | ||
// Works in Internet Explorer (all versions) | ||
event = document.createEvent("CustomEvent"); | ||
event.initCustomEvent(eventString, false, false, { instance }); | ||
} | ||
window.dispatchEvent(event); | ||
const createInstance = function(classObj, options) { | ||
var event; | ||
let eventString = "LazyLoad::Initialized"; | ||
let instance = new classObj(options); | ||
try { | ||
// Works in modern browsers | ||
event = new CustomEvent(eventString, { detail: { instance } }); | ||
} catch (err) { | ||
// Works in Internet Explorer (all versions) | ||
event = document.createEvent("CustomEvent"); | ||
event.initCustomEvent(eventString, false, false, { instance }); | ||
} | ||
window.dispatchEvent(event); | ||
}; | ||
@@ -69,12 +68,15 @@ | ||
options passed in (plain object or an array) */ | ||
function autoInitialize (classObj, options) { | ||
if (!options.length) { | ||
// Plain object | ||
createInstance(classObj, options); | ||
} else { | ||
// Array of objects | ||
for (let i = 0, optionsItem; optionsItem = options[i]; i += 1) { | ||
createInstance(classObj, optionsItem); | ||
} | ||
} | ||
function autoInitialize(classObj, options) { | ||
if (!options) { | ||
return; | ||
} | ||
if (!options.length) { | ||
// Plain object | ||
createInstance(classObj, options); | ||
} else { | ||
// Array of objects | ||
for (let i = 0, optionsItem; (optionsItem = options[i]); i += 1) { | ||
createInstance(classObj, optionsItem); | ||
} | ||
} | ||
} | ||
@@ -138,7 +140,8 @@ | ||
const runningOnBrowser = typeof window !== "undefined"; | ||
const isBot = | ||
!("onscroll" in window) || /glebot/.test(navigator.userAgent); | ||
(runningOnBrowser && !("onscroll" in window)) || | ||
/glebot|bingbot|crawler|spider|robot|crawling/i.test(navigator.userAgent); | ||
const runningOnBrowser = typeof window !== "undefined"; | ||
const supportsIntersectionObserver = | ||
@@ -298,6 +301,5 @@ runningOnBrowser && "IntersectionObserver" in window; | ||
/* Automatic instances creation if required (useful for async script loading!) */ | ||
let autoInitOptions = window.lazyLoadOptions; | ||
if (runningOnBrowser && autoInitOptions) { | ||
autoInitialize(LazyLoad, autoInitOptions); | ||
/* Automatic instances creation if required (useful for async script loading) */ | ||
if (runningOnBrowser) { | ||
autoInitialize(LazyLoad, window.lazyLoadOptions); | ||
} | ||
@@ -304,0 +306,0 @@ |
@@ -75,2 +75,5 @@ var _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; }; | ||
function autoInitialize(classObj, options) { | ||
if (!options) { | ||
return; | ||
} | ||
if (!options.length) { | ||
@@ -139,6 +142,6 @@ // Plain object | ||
var isBot = !("onscroll" in window) || /glebot/.test(navigator.userAgent); | ||
var runningOnBrowser = typeof window !== "undefined"; | ||
var isBot = runningOnBrowser && !("onscroll" in window) || /glebot|bingbot|crawler|spider|robot|crawling/i.test(navigator.userAgent); | ||
var supportsIntersectionObserver = runningOnBrowser && "IntersectionObserver" in window; | ||
@@ -296,6 +299,5 @@ | ||
/* Automatic instances creation if required (useful for async script loading!) */ | ||
var autoInitOptions = window.lazyLoadOptions; | ||
if (runningOnBrowser && autoInitOptions) { | ||
autoInitialize(LazyLoad, autoInitOptions); | ||
/* Automatic instances creation if required (useful for async script loading) */ | ||
if (runningOnBrowser) { | ||
autoInitialize(LazyLoad, window.lazyLoadOptions); | ||
} | ||
@@ -302,0 +304,0 @@ |
@@ -1,1 +0,1 @@ | ||
var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";function e(e){return e.filter(function(e){return!a(e)})}function t(e,t,n){!n&&a(e)||(h(t.callback_enter,e),["IMG","IFRAME","VIDEO"].indexOf(e.tagName)>-1&&(y(e,t),m(e,t.class_loading)),u(e,t),o(e),h(t.callback_set,e))}var n=function(e){var t={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null,callback_enter:null};return _extends({},t,e)},r=function(e,t){return e.getAttribute("data-"+t)},s=function(e,t,n){return e.setAttribute("data-"+t,n)},o=function(e){return s(e,"was-processed","true")},a=function(e){return"true"===r(e,"was-processed")},i=function(e,t){var n,r=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:r}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:r})}window.dispatchEvent(n)},c=function(e,t,n){for(var s,o=0;s=e.children[o];o+=1)if("SOURCE"===s.tagName){var a=r(s,n);a&&s.setAttribute(t,a)}},l=function(e,t,n){n&&e.setAttribute(t,n)},u=function(e,t){var n=t.data_sizes,s=t.data_srcset,o=t.data_src,a=r(e,o);switch(e.tagName){case"IMG":var i=e.parentNode;i&&"PICTURE"===i.tagName&&c(i,"srcset",s);var u=r(e,n);l(e,"sizes",u);var d=r(e,s);l(e,"srcset",d),l(e,"src",a);break;case"IFRAME":l(e,"src",a);break;case"VIDEO":c(e,"src",o),l(e,"src",a);break;default:a&&(e.style.backgroundImage='url("'+a+'")')}},d=!("onscroll"in window)||/glebot/.test(navigator.userAgent),f="undefined"!=typeof window,_=f&&"IntersectionObserver"in window,v=f&&"classList"in document.createElement("p"),m=function(e,t){v?e.classList.add(t):e.className+=(e.className?" ":"")+t},b=function(e,t){v?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},h=function(e,t){e&&e(t)},p=function(e,t,n){e.removeEventListener("load",t),e.removeEventListener("error",n)},y=function(e,t){var n=function n(s){g(s,!0,t),p(e,n,r)},r=function r(s){g(s,!1,t),p(e,n,r)};e.addEventListener("load",n),e.addEventListener("error",r)},g=function(e,t,n){var r=e.target;b(r,n.class_loading),m(r,t?n.class_loaded:n.class_error),h(t?n.callback_load:n.callback_error,r)},E=function(e){return e.isIntersecting||e.intersectionRatio>0},w=function(e){return{root:e.container===document?null:e.container,rootMargin:e.threshold+"px"}},L=function(e,t){this._settings=n(e),this._setObserver(),this.update(t)};L.prototype={_setObserver:function(){var t=this;if(_){this._observer=new IntersectionObserver(function(n){n.forEach(function(e){if(E(e)){var n=e.target;t.load(n),t._observer.unobserve(n)}}),t._elements=e(t._elements)},w(this._settings))}},loadAll:function(){var t=this;this._elements.forEach(function(e){t.load(e)}),this._elements=e(this._elements)},update:function(t){var n=this,r=this._settings,s=t||r.container.querySelectorAll(r.elements_selector);this._elements=e(Array.prototype.slice.call(s)),!d&&this._observer?this._elements.forEach(function(e){n._observer.observe(e)}):this.loadAll()},destroy:function(){var t=this;this._observer&&(e(this._elements).forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(e,n){t(e,this._settings,n)}};var I=window.lazyLoadOptions;return f&&I&&function(e,t){if(t.length)for(var n,r=0;n=t[r];r+=1)i(e,n);else i(e,t)}(L,I),L}); | ||
var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};!function(e,t){"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.LazyLoad=t()}(this,function(){"use strict";var r="data-",s="was-processed",o="true",l=function(e,t){return e.getAttribute(r+t)},a=function(e){return t=s,n=o,e.setAttribute(r+t,n);var t,n},i=function(e){return l(e,s)===o};function c(e){return e.filter(function(e){return!i(e)})}var u=function(e,t){var n,r="LazyLoad::Initialized",s=new e(t);try{n=new CustomEvent(r,{detail:{instance:s}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent(r,!1,!1,{instance:s})}window.dispatchEvent(n)};var d=function(e,t,n){for(var r,s=0;r=e.children[s];s+=1)if("SOURCE"===r.tagName){var o=l(r,n);o&&r.setAttribute(t,o)}},f=function(e,t,n){n&&e.setAttribute(t,n)},v=function(e,t){var n=t.data_sizes,r=t.data_srcset,s=t.data_src,o=l(e,s);switch(e.tagName){case"IMG":var a=e.parentNode;a&&"PICTURE"===a.tagName&&d(a,"srcset",r);var i=l(e,n);f(e,"sizes",i);var c=l(e,r);f(e,"srcset",c),f(e,"src",o);break;case"IFRAME":f(e,"src",o);break;case"VIDEO":d(e,"src",s),f(e,"src",o);break;default:o&&(e.style.backgroundImage='url("'+o+'")')}},e="undefined"!=typeof window,_=e&&!("onscroll"in window)||/glebot|bingbot|crawler|spider|robot|crawling/i.test(navigator.userAgent),t=e&&"IntersectionObserver"in window,b=e&&"classList"in document.createElement("p"),m=function(e,t){b?e.classList.add(t):e.className+=(e.className?" ":"")+t},h=function(e,t){e&&e(t)},p="load",y="error",g=function(e,t,n){e.removeEventListener(p,t),e.removeEventListener(y,n)},E=function(n,r){var s=function e(t){w(t,!0,r),g(n,e,o)},o=function e(t){w(t,!1,r),g(n,s,e)};n.addEventListener(p,s),n.addEventListener(y,o)},w=function(e,t,n){var r,s,o=e.target;r=o,s=n.class_loading,b?r.classList.remove(s):r.className=r.className.replace(new RegExp("(^|\\s+)"+s+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,""),m(o,t?n.class_loaded:n.class_error),h(t?n.callback_load:n.callback_error,o)};var n=function(e,t){var n;this._settings=(n={elements_selector:"img",container:document,threshold:300,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",class_loading:"loading",class_loaded:"loaded",class_error:"error",callback_load:null,callback_error:null,callback_set:null,callback_enter:null},_extends({},n,e)),this._setObserver(),this.update(t)};return n.prototype={_setObserver:function(){var r=this;if(t){var e;this._observer=new IntersectionObserver(function(e){e.forEach(function(e){if((n=e).isIntersecting||0<n.intersectionRatio){var t=e.target;r.load(t),r._observer.unobserve(t)}var n}),r._elements=c(r._elements)},{root:(e=this._settings).container===document?null:e.container,rootMargin:e.threshold+"px"})}},loadAll:function(){var t=this;this._elements.forEach(function(e){t.load(e)}),this._elements=c(this._elements)},update:function(e){var t=this,n=this._settings,r=e||n.container.querySelectorAll(n.elements_selector);this._elements=c(Array.prototype.slice.call(r)),!_&&this._observer?this._elements.forEach(function(e){t._observer.observe(e)}):this.loadAll()},destroy:function(){var t=this;this._observer&&(c(this._elements).forEach(function(e){t._observer.unobserve(e)}),this._observer=null),this._elements=null,this._settings=null},load:function(e,t){var n,r;n=e,r=this._settings,!t&&i(n)||(h(r.callback_enter,n),-1<["IMG","IFRAME","VIDEO"].indexOf(n.tagName)&&(E(n,r),m(n,r.class_loading)),v(n,r),a(n),h(r.callback_set,n))}},e&&function(e,t){if(t)if(t.length)for(var n,r=0;n=t[r];r+=1)u(e,n);else u(e,t)}(n,window.lazyLoadOptions),n}); |
{ | ||
"name": "vanilla-lazyload", | ||
"version": "10.11.1", | ||
"version": "10.12.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", | ||
@@ -5,0 +5,0 @@ "main": "dist/lazyload.min.js", |
@@ -15,3 +15,3 @@ LazyLoad is a fast, lightweight and flexible script that _speeds up your web application_ by **loading images, video or iframes as they enter the viewport**. It's written in plain "vanilla" JavaScript, uses [Intersection Observers](https://developer.mozilla.org/en-US/docs/Web/API/Intersection_Observer_API), and supports [responsive images](https://alistapart.com/article/responsive-images-in-practice). It's also SEO-friendly and it has some other [notable features](#notable-features). | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/8.11.0/lazyload.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/8.12.0/lazyload.min.js"></script> | ||
``` | ||
@@ -24,3 +24,3 @@ | ||
```html | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/10.11.1/lazyload.min.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/10.12.0/lazyload.min.js"></script> | ||
``` | ||
@@ -37,3 +37,3 @@ | ||
var s = d.createElement("script"); s.async = true; | ||
var v = !("IntersectionObserver" in w) ? "8.11.0" : "10.11.1"; | ||
var v = !("IntersectionObserver" in w) ? "8.12.0" : "10.12.0"; | ||
s.src = "https://cdnjs.cloudflare.com/ajax/libs/vanilla-lazyload/" + v + "/lazyload.min.js"; | ||
@@ -54,6 +54,6 @@ w.lazyLoadOptions = {}; // Your options here. See "recipes" for more information about async. | ||
- **install it with npm** | ||
Recommended version `npm install vanilla-lazyload@8.11.0` | ||
Recommended version `npm install vanilla-lazyload@8.12.0` | ||
Latest version `npm install vanilla-lazyload` | ||
- **install it with bower** | ||
Recommended version `bower install vanilla-lazyload#8.11.0` | ||
Recommended version `bower install vanilla-lazyload#8.12.0` | ||
Latest version `bower install vanilla-lazyload` | ||
@@ -539,6 +539,6 @@ | ||
| Required | What to pass | Type | Default value | | ||
| -------- | ----------------------------------------------- | ------- | ------------- | | ||
| No | The option object for this instance of LazyLoad | Plain Object | `{}` | | ||
| No | A NodeSet of elements to execute LazyLoad on | NodeSet | `null` | | ||
| Required | What to pass | Type | Default value | | ||
| -------- | ----------------------------------------------- | ------------ | ------------- | | ||
| No | The option object for this instance of LazyLoad | Plain Object | `{}` | | ||
| No | A NodeSet of elements to execute LazyLoad on | NodeSet | `null` | | ||
@@ -565,17 +565,17 @@ The most common usage of LazyLoad constructor is to pass only the options object (see "options" in the next section). For example: | ||
| Name | Meaning | Default value | | ||
| ---- | ----| ---- | | ||
| `container` | The scrolling container, and the container of the elements in the `elements_selector` option. | `document` | | ||
| `elements_selector` | The string selector of the elements to load lazily, to be selected as descendants of the `container` object. For multiple elements, you can add the css selectors for the same followed by a comma. E.g.: `'iframe, img, .container_class'`. This will lazy load images for iframe and img elements along with the images/background images under `'container_class'` | `"img"` | | ||
| `threshold` | The distance out of the viewport, expressed in pixel, before which to start loading the images | `300` | | ||
| `data_src` | The name of the data attribute containing the original image source, excluding the `"data-"` part. E.g. if your data attribute is named `"data-src"`, just pass `"src"` | `"src"` | | ||
| `data_srcset` | The name of the data attribute containing the original image source set in either `img` and `source` tags, excluding the `"data-"` part. E.g. if your data attribute is named `"data-original-set"`, just pass `"original-set"` | `"srcset"` | | ||
| `data_sizes` | The name of the data attribute containing the sizes attribute to use, excluding the `"data-"` part. E.g. if your data attribute is named `"data-sizes"`, just pass `"sizes"` | `"sizes"` | | ||
| `class_loading` | The class applied to the elements while the loading is in progress. | `"loading"` | | ||
| `class_loaded` | The class applied to the elements when the loading is complete | `"loaded"` | | ||
| `class_error` | The class applied to the elements when the element causes an error | `"error"` | | ||
| `callback_enter` | A function to be called when the DOM element enters the viewport. | `null` | | ||
| `callback_set` | A function to be called after the src of an image is set in the DOM. | `null` | | ||
| `callback_load` | A function to be called when an element was loaded. | `null` | | ||
| `callback_error` | A function to be called when an element triggers an error. | `null` | | ||
| Name | Meaning | Default value | | ||
| ------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | | ||
| `container` | The scrolling container, and the container of the elements in the `elements_selector` option. | `document` | | ||
| `elements_selector` | The string selector of the elements to load lazily, to be selected as descendants of the `container` object. For multiple elements, you can add the css selectors for the same followed by a comma. E.g.: `'iframe, img, .container_class'`. This will lazy load images for iframe and img elements along with the images/background images under `'container_class'` | `"img"` | | ||
| `threshold` | The distance out of the viewport, expressed in pixel, before which to start loading the images | `300` | | ||
| `data_src` | The name of the data attribute containing the original image source, excluding the `"data-"` part. E.g. if your data attribute is named `"data-src"`, just pass `"src"` | `"src"` | | ||
| `data_srcset` | The name of the data attribute containing the original image source set in either `img` and `source` tags, excluding the `"data-"` part. E.g. if your data attribute is named `"data-original-set"`, just pass `"original-set"` | `"srcset"` | | ||
| `data_sizes` | The name of the data attribute containing the sizes attribute to use, excluding the `"data-"` part. E.g. if your data attribute is named `"data-sizes"`, just pass `"sizes"` | `"sizes"` | | ||
| `class_loading` | The class applied to the elements while the loading is in progress. | `"loading"` | | ||
| `class_loaded` | The class applied to the elements when the loading is complete | `"loaded"` | | ||
| `class_error` | The class applied to the elements when the element causes an error | `"error"` | | ||
| `callback_enter` | A function to be called when the DOM element enters the viewport. | `null` | | ||
| `callback_set` | A function to be called after the src of an image is set in the DOM. | `null` | | ||
| `callback_load` | A function to be called when an element was loaded. | `null` | | ||
| `callback_error` | A function to be called when an element triggers an error. | `null` | | ||
@@ -586,8 +586,8 @@ ### Methods | ||
| Method name | Effect | | ||
|------------------|-------------------------------------------------------------------------------------------------------| | ||
| `update()` | Make LazyLoad to check for new lazy images in the container, using the `elements_selector` option. | | ||
| `loadAll()` | Loads all the lazy images right away, no matter if they are inside or outside the viewport. | | ||
| Method name | Effect | | ||
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| `update()` | Make LazyLoad to check for new lazy images in the container, using the `elements_selector` option. | | ||
| `loadAll()` | Loads all the lazy images right away, no matter if they are inside or outside the viewport. | | ||
| `load(element, force)` | Immediately loads any lazy `element`, even if it isn't selectable by the `elements_selector` option. Note that this method works only once on a specific `element`, unless you force it passing `true` as second parameter. | | ||
| `destroy()` | Destroys the instance, unsetting instance variables and removing listeners. | | ||
| `destroy()` | Destroys the instance, unsetting instance variables and removing listeners. | | ||
@@ -594,0 +594,0 @@ ## Notable features |
/* Creates instance and notifies it through the window element */ | ||
const createInstance = function (classObj, options) { | ||
var event; | ||
let eventString = "LazyLoad::Initialized"; | ||
let instance = new classObj(options); | ||
try { | ||
// Works in modern browsers | ||
event = new CustomEvent(eventString, { detail: { instance } }); | ||
} | ||
catch(err) { | ||
// Works in Internet Explorer (all versions) | ||
event = document.createEvent("CustomEvent"); | ||
event.initCustomEvent(eventString, false, false, { instance }); | ||
} | ||
window.dispatchEvent(event); | ||
const createInstance = function(classObj, options) { | ||
var event; | ||
let eventString = "LazyLoad::Initialized"; | ||
let instance = new classObj(options); | ||
try { | ||
// Works in modern browsers | ||
event = new CustomEvent(eventString, { detail: { instance } }); | ||
} catch (err) { | ||
// Works in Internet Explorer (all versions) | ||
event = document.createEvent("CustomEvent"); | ||
event.initCustomEvent(eventString, false, false, { instance }); | ||
} | ||
window.dispatchEvent(event); | ||
}; | ||
@@ -20,12 +19,15 @@ | ||
options passed in (plain object or an array) */ | ||
export default function (classObj, options) { | ||
if (!options.length) { | ||
// Plain object | ||
createInstance(classObj, options); | ||
} else { | ||
// Array of objects | ||
for (let i = 0, optionsItem; optionsItem = options[i]; i += 1) { | ||
createInstance(classObj, optionsItem); | ||
} | ||
} | ||
}; | ||
export default function(classObj, options) { | ||
if (!options) { | ||
return; | ||
} | ||
if (!options.length) { | ||
// Plain object | ||
createInstance(classObj, options); | ||
} else { | ||
// Array of objects | ||
for (let i = 0, optionsItem; (optionsItem = options[i]); i += 1) { | ||
createInstance(classObj, optionsItem); | ||
} | ||
} | ||
} |
@@ -0,6 +1,7 @@ | ||
export const runningOnBrowser = typeof window !== "undefined"; | ||
export const isBot = | ||
!("onscroll" in window) || /glebot/.test(navigator.userAgent); | ||
(runningOnBrowser && !("onscroll" in window)) || | ||
/glebot|bingbot|crawler|spider|robot|crawling/i.test(navigator.userAgent); | ||
export const runningOnBrowser = typeof window !== "undefined"; | ||
export const supportsIntersectionObserver = | ||
@@ -7,0 +8,0 @@ runningOnBrowser && "IntersectionObserver" in window; |
@@ -83,8 +83,7 @@ import getInstanceSettings from "./lazyload.defaults"; | ||
/* Automatic instances creation if required (useful for async script loading!) */ | ||
let autoInitOptions = window.lazyLoadOptions; | ||
if (runningOnBrowser && autoInitOptions) { | ||
autoInitialize(LazyLoad, autoInitOptions); | ||
/* Automatic instances creation if required (useful for async script loading) */ | ||
if (runningOnBrowser) { | ||
autoInitialize(LazyLoad, window.lazyLoadOptions); | ||
} | ||
export default LazyLoad; |
Sorry, the diff of this file is not supported yet
958774
1194