Lazy Load by WP Rocket - Version 1.4.9

Version Description

  • Enhancement: Update lazyload script to the latest available version
  • Enhancement: Use lazy-sizes to prevent W3C validation error when sizes is defined but srcset is not
  • Enhancement: Parse images or iframes only if the element is selected to be lazyloaded in the options
  • Fix: Prevent warning for lazyload+v in Google Search Console
  • Fix: Prevent PHP Notice with WooCommerce for product images
Download this release

Release Info

Developer wp_media
Plugin Icon 128x128 Lazy Load by WP Rocket
Version 1.4.9
Comparing to
See all releases

Code changes from version 1.4.8 to 1.4.9

assets/js/lazyload-10.11.1.js ADDED
@@ -0,0 +1,301 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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; };
2
+
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
+
5
+ (function (global, factory) {
6
+ (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory();
7
+ })(this, function () {
8
+ 'use strict';
9
+
10
+ var getInstanceSettings = function getInstanceSettings(customSettings) {
11
+ var defaultSettings = {
12
+ elements_selector: "img",
13
+ container: document,
14
+ threshold: 300,
15
+ data_src: "src",
16
+ data_srcset: "srcset",
17
+ data_sizes: "sizes",
18
+ class_loading: "loading",
19
+ class_loaded: "loaded",
20
+ class_error: "error",
21
+ callback_load: null,
22
+ callback_error: null,
23
+ callback_set: null,
24
+ callback_enter: null
25
+ };
26
+
27
+ return _extends({}, defaultSettings, customSettings);
28
+ };
29
+
30
+ var dataPrefix = "data-";
31
+ var processedDataName = "was-processed";
32
+ var processedDataValue = "true";
33
+
34
+ var getData = function getData(element, attribute) {
35
+ return element.getAttribute(dataPrefix + attribute);
36
+ };
37
+
38
+ var setData = function setData(element, attribute, value) {
39
+ return element.setAttribute(dataPrefix + attribute, value);
40
+ };
41
+
42
+ var setWasProcessed = function setWasProcessed(element) {
43
+ return setData(element, processedDataName, processedDataValue);
44
+ };
45
+
46
+ var getWasProcessed = function getWasProcessed(element) {
47
+ return getData(element, processedDataName) === processedDataValue;
48
+ };
49
+
50
+ function purgeElements(elements) {
51
+ return elements.filter(function (element) {
52
+ return !getWasProcessed(element);
53
+ });
54
+ }
55
+
56
+ /* Creates instance and notifies it through the window element */
57
+ var createInstance = function createInstance(classObj, options) {
58
+ var event;
59
+ var eventString = "LazyLoad::Initialized";
60
+ var instance = new classObj(options);
61
+ try {
62
+ // Works in modern browsers
63
+ event = new CustomEvent(eventString, { detail: { instance: instance } });
64
+ } catch (err) {
65
+ // Works in Internet Explorer (all versions)
66
+ event = document.createEvent("CustomEvent");
67
+ event.initCustomEvent(eventString, false, false, { instance: instance });
68
+ }
69
+ window.dispatchEvent(event);
70
+ };
71
+
72
+ /* Auto initialization of one or more instances of lazyload, depending on the
73
+ options passed in (plain object or an array) */
74
+ function autoInitialize(classObj, options) {
75
+ if (!options.length) {
76
+ // Plain object
77
+ createInstance(classObj, options);
78
+ } else {
79
+ // Array of objects
80
+ for (var i = 0, optionsItem; optionsItem = options[i]; i += 1) {
81
+ createInstance(classObj, optionsItem);
82
+ }
83
+ }
84
+ }
85
+
86
+ var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName) {
87
+ for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) {
88
+ if (childTag.tagName === "SOURCE") {
89
+ var attributeValue = getData(childTag, dataAttrName);
90
+ if (attributeValue) {
91
+ childTag.setAttribute(attrName, attributeValue);
92
+ }
93
+ }
94
+ }
95
+ };
96
+
97
+ var setAttributeIfNotNullOrEmpty = function setAttributeIfNotNullOrEmpty(element, attrName, value) {
98
+ if (!value) {
99
+ return;
100
+ }
101
+ element.setAttribute(attrName, value);
102
+ };
103
+
104
+ var setSources = function setSources(element, settings) {
105
+ var sizesDataName = settings.data_sizes,
106
+ srcsetDataName = settings.data_srcset,
107
+ srcDataName = settings.data_src;
108
+
109
+ var srcDataValue = getData(element, srcDataName);
110
+ switch (element.tagName) {
111
+ case "IMG":
112
+ {
113
+ var parent = element.parentNode;
114
+ if (parent && parent.tagName === "PICTURE") {
115
+ setSourcesInChildren(parent, "srcset", srcsetDataName);
116
+ }
117
+ var sizesDataValue = getData(element, sizesDataName);
118
+ setAttributeIfNotNullOrEmpty(element, "sizes", sizesDataValue);
119
+ var srcsetDataValue = getData(element, srcsetDataName);
120
+ setAttributeIfNotNullOrEmpty(element, "srcset", srcsetDataValue);
121
+ setAttributeIfNotNullOrEmpty(element, "src", srcDataValue);
122
+ break;
123
+ }
124
+ case "IFRAME":
125
+ setAttributeIfNotNullOrEmpty(element, "src", srcDataValue);
126
+ break;
127
+ case "VIDEO":
128
+ setSourcesInChildren(element, "src", srcDataName);
129
+ setAttributeIfNotNullOrEmpty(element, "src", srcDataValue);
130
+ break;
131
+ default:
132
+ if (srcDataValue) {
133
+ element.style.backgroundImage = 'url("' + srcDataValue + '")';
134
+ }
135
+ }
136
+ };
137
+
138
+ var isBot = !("onscroll" in window) || /glebot/.test(navigator.userAgent);
139
+
140
+ var runningOnBrowser = typeof window !== "undefined";
141
+
142
+ var supportsIntersectionObserver = runningOnBrowser && "IntersectionObserver" in window;
143
+
144
+ var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
145
+
146
+ var addClass = function addClass(element, className) {
147
+ if (supportsClassList) {
148
+ element.classList.add(className);
149
+ return;
150
+ }
151
+ element.className += (element.className ? " " : "") + className;
152
+ };
153
+
154
+ var removeClass = function removeClass(element, className) {
155
+ if (supportsClassList) {
156
+ element.classList.remove(className);
157
+ return;
158
+ }
159
+ element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
160
+ };
161
+
162
+ var callCallback = function callCallback(callback, argument) {
163
+ if (callback) {
164
+ callback(argument);
165
+ }
166
+ };
167
+
168
+ var loadString = "load";
169
+ var errorString = "error";
170
+
171
+ var removeListeners = function removeListeners(element, loadHandler, errorHandler) {
172
+ element.removeEventListener(loadString, loadHandler);
173
+ element.removeEventListener(errorString, errorHandler);
174
+ };
175
+
176
+ var addOneShotListeners = function addOneShotListeners(element, settings) {
177
+ var onLoad = function onLoad(event) {
178
+ onEvent(event, true, settings);
179
+ removeListeners(element, onLoad, onError);
180
+ };
181
+ var onError = function onError(event) {
182
+ onEvent(event, false, settings);
183
+ removeListeners(element, onLoad, onError);
184
+ };
185
+ element.addEventListener(loadString, onLoad);
186
+ element.addEventListener(errorString, onError);
187
+ };
188
+
189
+ var onEvent = function onEvent(event, success, settings) {
190
+ var element = event.target;
191
+ removeClass(element, settings.class_loading);
192
+ addClass(element, success ? settings.class_loaded : settings.class_error); // Setting loaded or error class
193
+ callCallback(success ? settings.callback_load : settings.callback_error, element);
194
+ };
195
+
196
+ function revealElement(element, settings, force) {
197
+ if (!force && getWasProcessed(element)) {
198
+ return; // element has already been processed and force wasn't true
199
+ }
200
+ callCallback(settings.callback_enter, element);
201
+ if (["IMG", "IFRAME", "VIDEO"].indexOf(element.tagName) > -1) {
202
+ addOneShotListeners(element, settings);
203
+ addClass(element, settings.class_loading);
204
+ }
205
+ setSources(element, settings);
206
+ setWasProcessed(element);
207
+ callCallback(settings.callback_set, element);
208
+ }
209
+
210
+ /* entry.isIntersecting needs fallback because is null on some versions of MS Edge, and
211
+ entry.intersectionRatio is not enough alone because it could be 0 on some intersecting elements */
212
+ var isIntersecting = function isIntersecting(element) {
213
+ return element.isIntersecting || element.intersectionRatio > 0;
214
+ };
215
+
216
+ var getObserverSettings = function getObserverSettings(settings) {
217
+ return {
218
+ root: settings.container === document ? null : settings.container,
219
+ rootMargin: settings.threshold + "px"
220
+ };
221
+ };
222
+
223
+ var LazyLoad = function LazyLoad(customSettings, elements) {
224
+ this._settings = getInstanceSettings(customSettings);
225
+ this._setObserver();
226
+ this.update(elements);
227
+ };
228
+
229
+ LazyLoad.prototype = {
230
+ _setObserver: function _setObserver() {
231
+ var _this = this;
232
+
233
+ if (!supportsIntersectionObserver) {
234
+ return;
235
+ }
236
+ var revealIntersectingElements = function revealIntersectingElements(entries) {
237
+ entries.forEach(function (entry) {
238
+ if (isIntersecting(entry)) {
239
+ var element = entry.target;
240
+ _this.load(element);
241
+ _this._observer.unobserve(element);
242
+ }
243
+ });
244
+ _this._elements = purgeElements(_this._elements);
245
+ };
246
+ this._observer = new IntersectionObserver(revealIntersectingElements, getObserverSettings(this._settings));
247
+ },
248
+
249
+ loadAll: function loadAll() {
250
+ var _this2 = this;
251
+
252
+ this._elements.forEach(function (element) {
253
+ _this2.load(element);
254
+ });
255
+ this._elements = purgeElements(this._elements);
256
+ },
257
+
258
+ update: function update(elements) {
259
+ var _this3 = this;
260
+
261
+ var settings = this._settings;
262
+ var nodeSet = elements || settings.container.querySelectorAll(settings.elements_selector);
263
+
264
+ this._elements = purgeElements(Array.prototype.slice.call(nodeSet)); // nodeset to array for IE compatibility
265
+
266
+ if (isBot || !this._observer) {
267
+ this.loadAll();
268
+ return;
269
+ }
270
+
271
+ this._elements.forEach(function (element) {
272
+ _this3._observer.observe(element);
273
+ });
274
+ },
275
+
276
+ destroy: function destroy() {
277
+ var _this4 = this;
278
+
279
+ if (this._observer) {
280
+ purgeElements(this._elements).forEach(function (element) {
281
+ _this4._observer.unobserve(element);
282
+ });
283
+ this._observer = null;
284
+ }
285
+ this._elements = null;
286
+ this._settings = null;
287
+ },
288
+
289
+ load: function load(element, force) {
290
+ revealElement(element, this._settings, force);
291
+ }
292
+ };
293
+
294
+ /* Automatic instances creation if required (useful for async script loading!) */
295
+ var autoInitOptions = window.lazyLoadOptions;
296
+ if (runningOnBrowser && autoInitOptions) {
297
+ autoInitialize(LazyLoad, autoInitOptions);
298
+ }
299
+
300
+ return LazyLoad;
301
+ });
assets/js/lazyload-10.11.1.min.js ADDED
@@ -0,0 +1 @@
 
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});
assets/js/lazyload-8.11.js ADDED
@@ -0,0 +1,389 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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; };
2
+
3
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4
+
5
+ (function (global, factory) {
6
+ (typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.LazyLoad = factory();
7
+ })(this, function () {
8
+ 'use strict';
9
+
10
+ var getDefaultSettings = function getDefaultSettings() {
11
+ return {
12
+ elements_selector: "img",
13
+ container: window,
14
+ threshold: 300,
15
+ throttle: 150,
16
+ data_src: "src",
17
+ data_srcset: "srcset",
18
+ data_sizes: "sizes",
19
+ class_loading: "loading",
20
+ class_loaded: "loaded",
21
+ class_error: "error",
22
+ class_initial: "initial",
23
+ skip_invisible: true,
24
+ callback_load: null,
25
+ callback_error: null,
26
+ callback_set: null,
27
+ callback_processed: null,
28
+ callback_enter: null
29
+ };
30
+ };
31
+
32
+ var isBot = !("onscroll" in window) || /glebot/.test(navigator.userAgent);
33
+
34
+ var callCallback = function callCallback(callback, argument) {
35
+ if (callback) {
36
+ callback(argument);
37
+ }
38
+ };
39
+
40
+ var getTopOffset = function getTopOffset(element) {
41
+ return element.getBoundingClientRect().top + window.pageYOffset - element.ownerDocument.documentElement.clientTop;
42
+ };
43
+
44
+ var isBelowViewport = function isBelowViewport(element, container, threshold) {
45
+ var fold = container === window ? window.innerHeight + window.pageYOffset : getTopOffset(container) + container.offsetHeight;
46
+ return fold <= getTopOffset(element) - threshold;
47
+ };
48
+
49
+ var getLeftOffset = function getLeftOffset(element) {
50
+ return element.getBoundingClientRect().left + window.pageXOffset - element.ownerDocument.documentElement.clientLeft;
51
+ };
52
+
53
+ var isAtRightOfViewport = function isAtRightOfViewport(element, container, threshold) {
54
+ var documentWidth = window.innerWidth;
55
+ var fold = container === window ? documentWidth + window.pageXOffset : getLeftOffset(container) + documentWidth;
56
+ return fold <= getLeftOffset(element) - threshold;
57
+ };
58
+
59
+ var isAboveViewport = function isAboveViewport(element, container, threshold) {
60
+ var fold = container === window ? window.pageYOffset : getTopOffset(container);
61
+ return fold >= getTopOffset(element) + threshold + element.offsetHeight;
62
+ };
63
+
64
+ var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) {
65
+ var fold = container === window ? window.pageXOffset : getLeftOffset(container);
66
+ return fold >= getLeftOffset(element) + threshold + element.offsetWidth;
67
+ };
68
+
69
+ function isInsideViewport(element, container, threshold) {
70
+ return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold);
71
+ }
72
+
73
+ /* Creates instance and notifies it through the window element */
74
+ var createInstance = function createInstance(classObj, options) {
75
+ var event;
76
+ var eventString = "LazyLoad::Initialized";
77
+ var instance = new classObj(options);
78
+ try {
79
+ // Works in modern browsers
80
+ event = new CustomEvent(eventString, { detail: { instance: instance } });
81
+ } catch (err) {
82
+ // Works in Internet Explorer (all versions)
83
+ event = document.createEvent("CustomEvent");
84
+ event.initCustomEvent(eventString, false, false, { instance: instance });
85
+ }
86
+ window.dispatchEvent(event);
87
+ };
88
+
89
+ /* Auto initialization of one or more instances of lazyload, depending on the
90
+ options passed in (plain object or an array) */
91
+ function autoInitialize(classObj, options) {
92
+ var optsLength = options.length;
93
+ if (!optsLength) {
94
+ // Plain object
95
+ createInstance(classObj, options);
96
+ } else {
97
+ // Array of objects
98
+ for (var i = 0; i < optsLength; i++) {
99
+ createInstance(classObj, options[i]);
100
+ }
101
+ }
102
+ }
103
+
104
+ var dataPrefix = "data-";
105
+ var processedDataName = "was-processed";
106
+ var processedDataValue = "true";
107
+
108
+ var getData = function getData(element, attribute) {
109
+ return element.getAttribute(dataPrefix + attribute);
110
+ };
111
+
112
+ var setData = function setData(element, attribute, value) {
113
+ return element.setAttribute(dataPrefix + attribute, value);
114
+ };
115
+
116
+ var setWasProcessed = function setWasProcessed(element) {
117
+ return setData(element, processedDataName, processedDataValue);
118
+ };
119
+
120
+ var getWasProcessed = function getWasProcessed(element) {
121
+ return getData(element, processedDataName) === processedDataValue;
122
+ };
123
+
124
+ var setSourcesInChildren = function setSourcesInChildren(parentTag, attrName, dataAttrName) {
125
+ for (var i = 0, childTag; childTag = parentTag.children[i]; i += 1) {
126
+ if (childTag.tagName === "SOURCE") {
127
+ var attributeValue = getData(childTag, dataAttrName);
128
+ if (attributeValue) {
129
+ childTag.setAttribute(attrName, attributeValue);
130
+ }
131
+ }
132
+ }
133
+ };
134
+
135
+ var setAttributeIfNotNullOrEmpty = function setAttributeIfNotNullOrEmpty(element, attrName, value) {
136
+ if (!value) {
137
+ return;
138
+ }
139
+ element.setAttribute(attrName, value);
140
+ };
141
+
142
+ function setSources(element, settings) {
143
+ var sizesDataName = settings.data_sizes,
144
+ srcsetDataName = settings.data_srcset,
145
+ srcDataName = settings.data_src;
146
+
147
+ var srcDataValue = getData(element, srcDataName);
148
+ var tagName = element.tagName;
149
+ if (tagName === "IMG") {
150
+ var parent = element.parentNode;
151
+ if (parent && parent.tagName === "PICTURE") {
152
+ setSourcesInChildren(parent, "srcset", srcsetDataName);
153
+ }
154
+ var sizesDataValue = getData(element, sizesDataName);
155
+ setAttributeIfNotNullOrEmpty(element, "sizes", sizesDataValue);
156
+ var srcsetDataValue = getData(element, srcsetDataName);
157
+ setAttributeIfNotNullOrEmpty(element, "srcset", srcsetDataValue);
158
+ setAttributeIfNotNullOrEmpty(element, "src", srcDataValue);
159
+ return;
160
+ }
161
+ if (tagName === "IFRAME") {
162
+ setAttributeIfNotNullOrEmpty(element, "src", srcDataValue);
163
+ return;
164
+ }
165
+ if (tagName === "VIDEO") {
166
+ setSourcesInChildren(element, "src", srcDataName);
167
+ setAttributeIfNotNullOrEmpty(element, "src", srcDataValue);
168
+ return;
169
+ }
170
+ if (srcDataValue) {
171
+ element.style.backgroundImage = 'url("' + srcDataValue + '")';
172
+ }
173
+ }
174
+
175
+ var runningOnBrowser = typeof window !== "undefined";
176
+
177
+ var supportsClassList = runningOnBrowser && "classList" in document.createElement("p");
178
+
179
+ var addClass = function addClass(element, className) {
180
+ if (supportsClassList) {
181
+ element.classList.add(className);
182
+ return;
183
+ }
184
+ element.className += (element.className ? " " : "") + className;
185
+ };
186
+
187
+ var removeClass = function removeClass(element, className) {
188
+ if (supportsClassList) {
189
+ element.classList.remove(className);
190
+ return;
191
+ }
192
+ element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
193
+ };
194
+
195
+ /*
196
+ * Constructor
197
+ */
198
+
199
+ var LazyLoad = function LazyLoad(instanceSettings) {
200
+ this._settings = _extends({}, getDefaultSettings(), instanceSettings);
201
+ this._queryOriginNode = this._settings.container === window ? document : this._settings.container;
202
+
203
+ this._previousLoopTime = 0;
204
+ this._loopTimeout = null;
205
+ this._boundHandleScroll = this.handleScroll.bind(this);
206
+
207
+ this._isFirstLoop = true;
208
+ window.addEventListener("resize", this._boundHandleScroll);
209
+ this.update();
210
+ };
211
+
212
+ LazyLoad.prototype = {
213
+ _reveal: function _reveal(element, force) {
214
+ if (!force && getWasProcessed(element)) {
215
+ return; // element has already been processed and force wasn't true
216
+ }
217
+
218
+ var settings = this._settings;
219
+
220
+ var errorCallback = function errorCallback() {
221
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
222
+ if (!settings) {
223
+ return;
224
+ }
225
+ element.removeEventListener("load", loadCallback);
226
+ element.removeEventListener("error", errorCallback);
227
+ removeClass(element, settings.class_loading);
228
+ addClass(element, settings.class_error);
229
+ callCallback(settings.callback_error, element);
230
+ };
231
+
232
+ var loadCallback = function loadCallback() {
233
+ /* As this method is asynchronous, it must be protected against external destroy() calls */
234
+ if (!settings) {
235
+ return;
236
+ }
237
+ removeClass(element, settings.class_loading);
238
+ addClass(element, settings.class_loaded);
239
+ element.removeEventListener("load", loadCallback);
240
+ element.removeEventListener("error", errorCallback);
241
+ callCallback(settings.callback_load, element);
242
+ };
243
+
244
+ callCallback(settings.callback_enter, element);
245
+ if (["IMG", "IFRAME", "VIDEO"].indexOf(element.tagName) > -1) {
246
+ element.addEventListener("load", loadCallback);
247
+ element.addEventListener("error", errorCallback);
248
+ addClass(element, settings.class_loading);
249
+ }
250
+ setSources(element, settings);
251
+ callCallback(settings.callback_set, element);
252
+ },
253
+
254
+ _loopThroughElements: function _loopThroughElements(forceDownload) {
255
+ var settings = this._settings,
256
+ elements = this._elements,
257
+ elementsLength = !elements ? 0 : elements.length;
258
+ var i = void 0,
259
+ processedIndexes = [],
260
+ firstLoop = this._isFirstLoop;
261
+
262
+ for (i = 0; i < elementsLength; i++) {
263
+ var element = elements[i];
264
+ /* If must skip_invisible and element is invisible, skip it */
265
+ if (settings.skip_invisible && element.offsetParent === null) {
266
+ continue;
267
+ }
268
+
269
+ if (isBot || forceDownload || isInsideViewport(element, settings.container, settings.threshold)) {
270
+ if (firstLoop) {
271
+ addClass(element, settings.class_initial);
272
+ }
273
+ /* Start loading the image */
274
+ this.load(element);
275
+ /* Marking the element as processed. */
276
+ processedIndexes.push(i);
277
+ setWasProcessed(element);
278
+ }
279
+ }
280
+ /* Removing processed elements from this._elements. */
281
+ while (processedIndexes.length) {
282
+ elements.splice(processedIndexes.pop(), 1);
283
+ callCallback(settings.callback_processed, elements.length);
284
+ }
285
+ /* Stop listening to scroll event when 0 elements remains */
286
+ if (elementsLength === 0) {
287
+ this._stopScrollHandler();
288
+ }
289
+ /* Sets isFirstLoop to false */
290
+ if (firstLoop) {
291
+ this._isFirstLoop = false;
292
+ }
293
+ },
294
+
295
+ _purgeElements: function _purgeElements() {
296
+ var elements = this._elements,
297
+ elementsLength = elements.length;
298
+ var i = void 0,
299
+ elementsToPurge = [];
300
+
301
+ for (i = 0; i < elementsLength; i++) {
302
+ var element = elements[i];
303
+ /* If the element has already been processed, skip it */
304
+ if (getWasProcessed(element)) {
305
+ elementsToPurge.push(i);
306
+ }
307
+ }
308
+ /* Removing elements to purge from this._elements. */
309
+ while (elementsToPurge.length > 0) {
310
+ elements.splice(elementsToPurge.pop(), 1);
311
+ }
312
+ },
313
+
314
+ _startScrollHandler: function _startScrollHandler() {
315
+ if (!this._isHandlingScroll) {
316
+ this._isHandlingScroll = true;
317
+ this._settings.container.addEventListener("scroll", this._boundHandleScroll);
318
+ }
319
+ },
320
+
321
+ _stopScrollHandler: function _stopScrollHandler() {
322
+ if (this._isHandlingScroll) {
323
+ this._isHandlingScroll = false;
324
+ this._settings.container.removeEventListener("scroll", this._boundHandleScroll);
325
+ }
326
+ },
327
+
328
+ handleScroll: function handleScroll() {
329
+ var throttle = this._settings.throttle;
330
+
331
+ if (throttle !== 0) {
332
+ var now = Date.now();
333
+ var remainingTime = throttle - (now - this._previousLoopTime);
334
+ if (remainingTime <= 0 || remainingTime > throttle) {
335
+ if (this._loopTimeout) {
336
+ clearTimeout(this._loopTimeout);
337
+ this._loopTimeout = null;
338
+ }
339
+ this._previousLoopTime = now;
340
+ this._loopThroughElements();
341
+ } else if (!this._loopTimeout) {
342
+ this._loopTimeout = setTimeout(function () {
343
+ this._previousLoopTime = Date.now();
344
+ this._loopTimeout = null;
345
+ this._loopThroughElements();
346
+ }.bind(this), remainingTime);
347
+ }
348
+ } else {
349
+ this._loopThroughElements();
350
+ }
351
+ },
352
+
353
+ loadAll: function loadAll() {
354
+ this._loopThroughElements(true);
355
+ },
356
+
357
+ update: function update() {
358
+ // Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector
359
+ this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));
360
+ this._purgeElements();
361
+ this._loopThroughElements();
362
+ this._startScrollHandler();
363
+ },
364
+
365
+ destroy: function destroy() {
366
+ window.removeEventListener("resize", this._boundHandleScroll);
367
+ if (this._loopTimeout) {
368
+ clearTimeout(this._loopTimeout);
369
+ this._loopTimeout = null;
370
+ }
371
+ this._stopScrollHandler();
372
+ this._elements = null;
373
+ this._queryOriginNode = null;
374
+ this._settings = null;
375
+ },
376
+
377
+ load: function load(element, force) {
378
+ this._reveal(element, force);
379
+ }
380
+ };
381
+
382
+ /* Automatic instances creation if required (useful for async script loading!) */
383
+ var autoInitOptions = window.lazyLoadOptions;
384
+ if (runningOnBrowser && autoInitOptions) {
385
+ autoInitialize(LazyLoad, autoInitOptions);
386
+ }
387
+
388
+ return LazyLoad;
389
+ });
assets/js/lazyload-8.11.min.js ADDED
@@ -0,0 +1 @@
 
1
+ var _extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}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 d=!("onscroll"in window)||/glebot/.test(navigator.userAgent),h=function(e,t){e&&e(t)},o=function(e){return e.getBoundingClientRect().top+window.pageYOffset-e.ownerDocument.documentElement.clientTop},f=function(e,t,n){return(t===window?window.innerHeight+window.pageYOffset:o(t)+t.offsetHeight)<=o(e)-n},i=function(e){return e.getBoundingClientRect().left+window.pageXOffset-e.ownerDocument.documentElement.clientLeft},_=function(e,t,n){var o=window.innerWidth;return(t===window?o+window.pageXOffset:i(t)+o)<=i(e)-n},p=function(e,t,n){return(t===window?window.pageYOffset:o(t))>=o(e)+n+e.offsetHeight},m=function(e,t,n){return(t===window?window.pageXOffset:i(t))>=i(e)+n+e.offsetWidth};var s=function(e,t){var n,o="LazyLoad::Initialized",i=new e(t);try{n=new CustomEvent(o,{detail:{instance:i}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent(o,!1,!1,{instance:i})}window.dispatchEvent(n)};var r="data-",l="was-processed",a="true",u=function(e,t){return e.getAttribute(r+t)},g=function(e){return t=l,n=a,e.setAttribute(r+t,n);var t,n},c=function(e){return u(e,l)===a},v=function(e,t,n){for(var o,i=0;o=e.children[i];i+=1)if("SOURCE"===o.tagName){var s=u(o,n);s&&o.setAttribute(t,s)}},w=function(e,t,n){n&&e.setAttribute(t,n)};var e="undefined"!=typeof window,n=e&&"classList"in document.createElement("p"),b=function(e,t){n?e.classList.add(t):e.className+=(e.className?" ":"")+t},y=function(e,t){n?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},t=function(e){this._settings=_extends({},{elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"src",data_srcset:"srcset",data_sizes:"sizes",class_loading:"loading",class_loaded:"loaded",class_error:"error",class_initial:"initial",skip_invisible:!0,callback_load:null,callback_error:null,callback_set:null,callback_processed:null,callback_enter:null},e),this._queryOriginNode=this._settings.container===window?document:this._settings.container,this._previousLoopTime=0,this._loopTimeout=null,this._boundHandleScroll=this.handleScroll.bind(this),this._isFirstLoop=!0,window.addEventListener("resize",this._boundHandleScroll),this.update()};t.prototype={_reveal:function(t,e){if(e||!c(t)){var n=this._settings,o=function e(){n&&(t.removeEventListener("load",i),t.removeEventListener("error",e),y(t,n.class_loading),b(t,n.class_error),h(n.callback_error,t))},i=function e(){n&&(y(t,n.class_loading),b(t,n.class_loaded),t.removeEventListener("load",e),t.removeEventListener("error",o),h(n.callback_load,t))};h(n.callback_enter,t),-1<["IMG","IFRAME","VIDEO"].indexOf(t.tagName)&&(t.addEventListener("load",i),t.addEventListener("error",o),b(t,n.class_loading)),function(e,t){var n=t.data_sizes,o=t.data_srcset,i=t.data_src,s=u(e,i),r=e.tagName;if("IMG"===r){var l=e.parentNode;l&&"PICTURE"===l.tagName&&v(l,"srcset",o);var a=u(e,n);w(e,"sizes",a);var c=u(e,o);return w(e,"srcset",c),w(e,"src",s)}if("IFRAME"!==r)return"VIDEO"===r?(v(e,"src",i),w(e,"src",s)):s&&(e.style.backgroundImage='url("'+s+'")');w(e,"src",s)}(t,n),h(n.callback_set,t)}},_loopThroughElements:function(e){var t,n,o,i=this._settings,s=this._elements,r=s?s.length:0,l=void 0,a=[],c=this._isFirstLoop;for(l=0;l<r;l++){var u=s[l];i.skip_invisible&&null===u.offsetParent||(!d&&!e&&(t=u,n=i.container,o=i.threshold,f(t,n,o)||p(t,n,o)||_(t,n,o)||m(t,n,o))||(c&&b(u,i.class_initial),this.load(u),a.push(l),g(u)))}for(;a.length;)s.splice(a.pop(),1),h(i.callback_processed,s.length);0===r&&this._stopScrollHandler(),c&&(this._isFirstLoop=!1)},_purgeElements:function(){var e=this._elements,t=e.length,n=void 0,o=[];for(n=0;n<t;n++){var i=e[n];c(i)&&o.push(n)}for(;0<o.length;)e.splice(o.pop(),1)},_startScrollHandler:function(){this._isHandlingScroll||(this._isHandlingScroll=!0,this._settings.container.addEventListener("scroll",this._boundHandleScroll))},_stopScrollHandler:function(){this._isHandlingScroll&&(this._isHandlingScroll=!1,this._settings.container.removeEventListener("scroll",this._boundHandleScroll))},handleScroll:function(){var e=this._settings.throttle;if(0!==e){var t=Date.now(),n=e-(t-this._previousLoopTime);n<=0||e<n?(this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._previousLoopTime=t,this._loopThroughElements()):this._loopTimeout||(this._loopTimeout=setTimeout(function(){this._previousLoopTime=Date.now(),this._loopTimeout=null,this._loopThroughElements()}.bind(this),n))}else this._loopThroughElements()},loadAll:function(){this._loopThroughElements(!0)},update:function(){this._elements=Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector)),this._purgeElements(),this._loopThroughElements(),this._startScrollHandler()},destroy:function(){window.removeEventListener("resize",this._boundHandleScroll),this._loopTimeout&&(clearTimeout(this._loopTimeout),this._loopTimeout=null),this._stopScrollHandler(),this._elements=null,this._queryOriginNode=null,this._settings=null},load:function(e,t){this._reveal(e,t)}};var E=window.lazyLoadOptions;return e&&E&&function(e,t){var n=t.length;if(n)for(var o=0;o<n;o++)s(e,t[o]);else s(e,t)}(t,E),t});
readme.txt CHANGED
@@ -1,18 +1,24 @@
1
  === Lazy Load by WP Rocket ===
2
  Contributors: creativejuiz, tabrisrp, wp_media
3
- Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
4
  Requires at least: 4.7
5
  Tested up to: 4.9
6
- Requires PHP: 5.3
7
- Stable tag: 1.4.8
8
 
9
- The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
10
 
11
  == Description ==
12
 
13
- Lazy Load displays images and/or iframes on a page only when they are visible to the user. This reduces the number of HTTP requests mechanism and improves the loading time.
14
 
15
- This plugin works on thumbnails, all images in a post content or in a widget text, avatars, smilies and iFrames. No JavaScript library such as jQuery is used and the script weight is less than 10KB.
 
 
 
 
 
 
16
 
17
  = Related Plugins =
18
  * <a href="https://wordpress.org/plugins/imagify/">Imagify</a>: Best Image Optimizer to speed up your website with lighter images.
@@ -64,6 +70,13 @@ add_filter( 'rocket_lazyload_threshold', 'rocket_lazyload_custom_threshold' );
64
  Some plugins are not compatible without lazy loading. Please open a support thread, and we will see how we can solve the issue by excluding lazy loading for this plugin.
65
 
66
  == Changelog ==
 
 
 
 
 
 
 
67
  = 1.4.8 =
68
  * Notice: Minimum WordPress version required is now 4.7
69
  * Enhancement: Update lazyload script version
1
  === Lazy Load by WP Rocket ===
2
  Contributors: creativejuiz, tabrisrp, wp_media
3
+ Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar, youtube
4
  Requires at least: 4.7
5
  Tested up to: 4.9
6
+ Requires PHP: 5.4
7
+ Stable tag: 1.4.9
8
 
9
+ Lazy Load your images and iframes, replace Youtube videos by a preview thumbnail.
10
 
11
  == Description ==
12
 
13
+ Lazy Load by WP Rocket displays images and/or iframes on a page only when they are visible to the user. This reduces the number of HTTP requests mechanism and improves the loading time.
14
 
15
+ This plugin works on thumbnails, all images in a post content or in a widget text, avatars, smilies and iframes. No JavaScript library such as jQuery is used and the script weight is less than 10KB.
16
+
17
+ You can also replace Youtube iframes by a preview thumbnail to further speed up the loading time of your website.
18
+
19
+ = Dependencies =
20
+
21
+ Lazyload script: https://github.com/verlok/lazyload
22
 
23
  = Related Plugins =
24
  * <a href="https://wordpress.org/plugins/imagify/">Imagify</a>: Best Image Optimizer to speed up your website with lighter images.
70
  Some plugins are not compatible without lazy loading. Please open a support thread, and we will see how we can solve the issue by excluding lazy loading for this plugin.
71
 
72
  == Changelog ==
73
+ = 1.4.9 =
74
+ * Enhancement: Update lazyload script to the latest available version
75
+ * Enhancement: Use lazy-sizes to prevent W3C validation error when sizes is defined but srcset is not
76
+ * Enhancement: Parse images or iframes only if the element is selected to be lazyloaded in the options
77
+ * Fix: Prevent warning for lazyload+v in Google Search Console
78
+ * Fix: Prevent PHP Notice with WooCommerce for product images
79
+
80
  = 1.4.8 =
81
  * Notice: Minimum WordPress version required is now 4.7
82
  * Enhancement: Update lazyload script version
rocket-lazy-load.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Lazy Load by WP Rocket
4
  * Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/
5
  * Description: The tiny Lazy Load script for WordPress without jQuery or others libraries.
6
- * Version: 1.4.8
7
  * Author: WP Media
8
  * Author URI: https://wp-rocket.me
9
  * Text Domain: rocket-lazy-load
@@ -27,7 +27,7 @@
27
 
28
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
29
 
30
- define( 'ROCKET_LL_VERSION', '1.4.8' );
31
  define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
32
  define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
33
  define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
@@ -59,7 +59,7 @@ if ( version_compare( PHP_VERSION, '5.3', '<' ) ) {
59
  * @since 1.3
60
  */
61
  function rocket_lazyload_php_warning() {
62
- echo '<div class="error"><p>' . __( 'Rocket LazyLoad requires PHP 5.3 to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'rocket-lazy-load' ) . '</p></div>';
63
  if ( isset( $_GET['activate'] ) ) { // WPCS: CSRF ok.
64
  unset( $_GET['activate'] );
65
  }
@@ -118,19 +118,29 @@ function rocket_lazyload_script() {
118
  */
119
  $threshold = apply_filters( 'rocket_lazyload_threshold', 300 );
120
 
 
 
 
 
 
 
 
 
 
 
121
  echo '<script>(function(w, d){
122
  var b = d.getElementsByTagName("body")[0];
123
  var s = d.createElement("script"); s.async = true;
124
- var v = !("IntersectionObserver" in w) ? "8.9" : "10.8";
125
- s.src = "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-" + v + "' . $suffix . '.js";
126
  w.lazyLoadOptions = {
127
- elements_selector: "img, iframe",
128
  data_src: "lazy-src",
129
  data_srcset: "lazy-srcset",
 
130
  skip_invisible: false,
131
  class_loading: "lazyloading",
132
  class_loaded: "lazyloaded",
133
- threshold: ' . $threshold . ',
134
  callback_load: function(element) {
135
  if ( element.tagName === "IFRAME" && element.dataset.rocketLazyload == "fitvidscompatible" ) {
136
  if (element.classList.contains("lazyloaded") ) {
@@ -173,7 +183,7 @@ window.addEventListener(\'LazyLoad::Initialized\', function (e) {
173
  *
174
  * @param string $thumbnail_resolution The resolution of the thumbnail. Accepted values: default, mqdefault, sddefault, hqdefault, maxresdefault
175
  */
176
- $thumbnail_resolution = apply_filters( 'rocket_youtube_thumbnail_resolution', 'hqdefault' );
177
 
178
  echo <<<HTML
179
  <script>function lazyLoadThumb(e){var t='<img src="https://i.ytimg.com/vi/ID/$thumbnail_resolution.jpg">',a='<div class="play"></div>';return t.replace("ID",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement("iframe"),t="https://www.youtube.com/embed/ID?autoplay=1";t+=0===this.dataset.query.length?'':'&'+this.dataset.query;e.setAttribute("src",t.replace("ID",this.dataset.id)),e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","1"),this.parentNode.replaceChild(e,this)}document.addEventListener("DOMContentLoaded",function(){var e,t,a=document.getElementsByClassName("rll-youtube-player");for(t=0;t<a.length;t++)e=document.createElement("div"),e.setAttribute("data-id",a[t].dataset.id),e.setAttribute("data-query", a[t].dataset.query),e.innerHTML=lazyLoadThumb(a[t].dataset.id),e.onclick=lazyLoadYoutubeIframe,a[t].appendChild(e)});</script>
@@ -329,9 +339,9 @@ function rocket_lazyload_on_srcset( $html ) {
329
  $html = str_replace( 'srcset=', 'data-lazy-srcset=', $html );
330
  }
331
 
332
- /**if ( preg_match( '/sizes=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))/i', $html ) ) {
333
  $html = str_replace( 'sizes=', 'data-lazy-sizes=', $html );
334
- }*/
335
 
336
  return $html;
337
  }
@@ -357,17 +367,22 @@ function rocket_lazyload_get_attachment_image( $attr ) {
357
  return $attr;
358
  }
359
 
360
- $attr['data-lazy-src'] = $attr['src'];
361
- $attr['src'] = apply_filters( 'rocket_lazyload_placeholder', '' );
362
 
363
  if ( isset( $attr['srcset'] ) ) {
364
  $attr['data-lazy-srcset'] = $attr['srcset'];
365
  unset( $attr['srcset'] );
366
  }
367
 
 
 
 
 
 
368
  return $attr;
369
  }
370
- add_filter( 'wp_get_attachment_image_attributes', 'rocket_lazyload_get_attachment_image' );
371
 
372
  /**
373
  * Replace WordPress smilies by Lazy Load
@@ -557,7 +572,7 @@ function rocket_lazyload_iframes( $html ) {
557
 
558
  $iframe_lazyload = str_replace( $iframe[1], $placeholder, $iframe[0] );
559
 
560
- $iframe_lazyload = str_replace( $iframe[2], ' data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . esc_url( $iframe[1] ) . '"' . $iframe[2], $iframe[0] );
561
  /**
562
  * Filter the LazyLoad HTML output on iframes
563
  *
3
  * Plugin Name: Lazy Load by WP Rocket
4
  * Plugin URI: http://wordpress.org/plugins/rocket-lazy-load/
5
  * Description: The tiny Lazy Load script for WordPress without jQuery or others libraries.
6
+ * Version: 1.4.9
7
  * Author: WP Media
8
  * Author URI: https://wp-rocket.me
9
  * Text Domain: rocket-lazy-load
27
 
28
  defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
29
 
30
+ define( 'ROCKET_LL_VERSION', '1.4.9' );
31
  define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
32
  define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
33
  define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
59
  * @since 1.3
60
  */
61
  function rocket_lazyload_php_warning() {
62
+ echo '<div class="error"><p>' . esc_html( __( 'Rocket LazyLoad requires PHP 5.3 to function properly. Please upgrade PHP. The Plugin has been auto-deactivated.', 'rocket-lazy-load' ) ) . '</p></div>';
63
  if ( isset( $_GET['activate'] ) ) { // WPCS: CSRF ok.
64
  unset( $_GET['activate'] );
65
  }
118
  */
119
  $threshold = apply_filters( 'rocket_lazyload_threshold', 300 );
120
 
121
+ $elements = [];
122
+
123
+ if ( rocket_lazyload_get_option( 'images' ) ) {
124
+ $elements[] = 'img';
125
+ }
126
+
127
+ if ( rocket_lazyload_get_option( 'iframes' ) ) {
128
+ $elements[] = 'iframe';
129
+ }
130
+
131
  echo '<script>(function(w, d){
132
  var b = d.getElementsByTagName("body")[0];
133
  var s = d.createElement("script"); s.async = true;
134
+ s.src = !("IntersectionObserver" in w) ? "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-8.11' . $suffix . '.js" : "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-10.11.1' . $suffix . '.js";
 
135
  w.lazyLoadOptions = {
136
+ elements_selector: "' . esc_attr( implode( ',', $elements ) ) . '",
137
  data_src: "lazy-src",
138
  data_srcset: "lazy-srcset",
139
+ data_sizes: "lazy-sizes",
140
  skip_invisible: false,
141
  class_loading: "lazyloading",
142
  class_loaded: "lazyloaded",
143
+ threshold: ' . esc_attr( $threshold ) . ',
144
  callback_load: function(element) {
145
  if ( element.tagName === "IFRAME" && element.dataset.rocketLazyload == "fitvidscompatible" ) {
146
  if (element.classList.contains("lazyloaded") ) {
183
  *
184
  * @param string $thumbnail_resolution The resolution of the thumbnail. Accepted values: default, mqdefault, sddefault, hqdefault, maxresdefault
185
  */
186
+ $thumbnail_resolution = apply_filters( 'rocket_lazyload_youtube_thumbnail_resolution', 'hqdefault' );
187
 
188
  echo <<<HTML
189
  <script>function lazyLoadThumb(e){var t='<img src="https://i.ytimg.com/vi/ID/$thumbnail_resolution.jpg">',a='<div class="play"></div>';return t.replace("ID",e)+a}function lazyLoadYoutubeIframe(){var e=document.createElement("iframe"),t="https://www.youtube.com/embed/ID?autoplay=1";t+=0===this.dataset.query.length?'':'&'+this.dataset.query;e.setAttribute("src",t.replace("ID",this.dataset.id)),e.setAttribute("frameborder","0"),e.setAttribute("allowfullscreen","1"),this.parentNode.replaceChild(e,this)}document.addEventListener("DOMContentLoaded",function(){var e,t,a=document.getElementsByClassName("rll-youtube-player");for(t=0;t<a.length;t++)e=document.createElement("div"),e.setAttribute("data-id",a[t].dataset.id),e.setAttribute("data-query", a[t].dataset.query),e.innerHTML=lazyLoadThumb(a[t].dataset.id),e.onclick=lazyLoadYoutubeIframe,a[t].appendChild(e)});</script>
339
  $html = str_replace( 'srcset=', 'data-lazy-srcset=', $html );
340
  }
341
 
342
+ if ( preg_match( '/sizes=("(?:[^"]+)"|\'(?:[^\']+)\'|(?:[^ >]+))/i', $html ) ) {
343
  $html = str_replace( 'sizes=', 'data-lazy-sizes=', $html );
344
+ }
345
 
346
  return $html;
347
  }
367
  return $attr;
368
  }
369
 
370
+ $attr['data-lazy-src'] = $attr['src'];
371
+ $attr['src'] = apply_filters( 'rocket_lazyload_placeholder', '' );
372
 
373
  if ( isset( $attr['srcset'] ) ) {
374
  $attr['data-lazy-srcset'] = $attr['srcset'];
375
  unset( $attr['srcset'] );
376
  }
377
 
378
+ if ( isset( $attr['sizes'] ) ) {
379
+ $attr['data-lazy-sizes'] = $attr['sizes'];
380
+ unset( $attr['sizes'] );
381
+ }
382
+
383
  return $attr;
384
  }
385
+ add_filter( 'wp_get_attachment_image_attributes', 'rocket_lazyload_get_attachment_image', 11 );
386
 
387
  /**
388
  * Replace WordPress smilies by Lazy Load
572
 
573
  $iframe_lazyload = str_replace( $iframe[1], $placeholder, $iframe[0] );
574
 
575
+ $iframe_lazyload = str_replace( $iframe[2], ' data-rocket-lazyload="fitvidscompatible" data-lazy-src="' . esc_url( $iframe[1] ) . '"' . $iframe[2], $iframe[0] );
576
  /**
577
  * Filter the LazyLoad HTML output on iframes
578
  *