Version Description
- Correctly include version 8.5.2 of lazyload script
- Prevent 404 error on lazyload script if URL contains "-v"
Download this release
Release Info
Developer | wp_media |
Plugin | Lazy Load by WP Rocket |
Version | 1.4.6 |
Comparing to | |
See all releases |
Code changes from version 1.4.5 to 1.4.6
- assets/js/lazyload-8.5.2.js +363 -0
- assets/js/lazyload-8.5.2.min.js +1 -0
- readme.txt +5 -2
- rocket-lazy-load.php +3 -3
assets/js/lazyload-8.5.2.js
ADDED
@@ -0,0 +1,363 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 defaultSettings = {
|
11 |
+
elements_selector: "img",
|
12 |
+
container: window,
|
13 |
+
threshold: 300,
|
14 |
+
throttle: 150,
|
15 |
+
data_src: "src",
|
16 |
+
data_srcset: "srcset",
|
17 |
+
class_loading: "loading",
|
18 |
+
class_loaded: "loaded",
|
19 |
+
class_error: "error",
|
20 |
+
class_initial: "initial",
|
21 |
+
skip_invisible: true,
|
22 |
+
callback_load: null,
|
23 |
+
callback_error: null,
|
24 |
+
callback_set: null,
|
25 |
+
callback_processed: null
|
26 |
+
};
|
27 |
+
|
28 |
+
var isBot = !("onscroll" in window) || /glebot/.test(navigator.userAgent);
|
29 |
+
|
30 |
+
var callCallback = function callCallback(callback, argument) {
|
31 |
+
if (callback) {
|
32 |
+
callback(argument);
|
33 |
+
}
|
34 |
+
};
|
35 |
+
|
36 |
+
var getTopOffset = function getTopOffset(element) {
|
37 |
+
return element.getBoundingClientRect().top + window.pageYOffset - element.ownerDocument.documentElement.clientTop;
|
38 |
+
};
|
39 |
+
|
40 |
+
var isBelowViewport = function isBelowViewport(element, container, threshold) {
|
41 |
+
var fold = container === window ? window.innerHeight + window.pageYOffset : getTopOffset(container) + container.offsetHeight;
|
42 |
+
return fold <= getTopOffset(element) - threshold;
|
43 |
+
};
|
44 |
+
|
45 |
+
var getLeftOffset = function getLeftOffset(element) {
|
46 |
+
return element.getBoundingClientRect().left + window.pageXOffset - element.ownerDocument.documentElement.clientLeft;
|
47 |
+
};
|
48 |
+
|
49 |
+
var isAtRightOfViewport = function isAtRightOfViewport(element, container, threshold) {
|
50 |
+
var documentWidth = window.innerWidth;
|
51 |
+
var fold = container === window ? documentWidth + window.pageXOffset : getLeftOffset(container) + documentWidth;
|
52 |
+
return fold <= getLeftOffset(element) - threshold;
|
53 |
+
};
|
54 |
+
|
55 |
+
var isAboveViewport = function isAboveViewport(element, container, threshold) {
|
56 |
+
var fold = container === window ? window.pageYOffset : getTopOffset(container);
|
57 |
+
return fold >= getTopOffset(element) + threshold + element.offsetHeight;
|
58 |
+
};
|
59 |
+
|
60 |
+
var isAtLeftOfViewport = function isAtLeftOfViewport(element, container, threshold) {
|
61 |
+
var fold = container === window ? window.pageXOffset : getLeftOffset(container);
|
62 |
+
return fold >= getLeftOffset(element) + threshold + element.offsetWidth;
|
63 |
+
};
|
64 |
+
|
65 |
+
var isInsideViewport = function isInsideViewport(element, container, threshold) {
|
66 |
+
return !isBelowViewport(element, container, threshold) && !isAboveViewport(element, container, threshold) && !isAtRightOfViewport(element, container, threshold) && !isAtLeftOfViewport(element, container, threshold);
|
67 |
+
};
|
68 |
+
|
69 |
+
/* Creates instance and notifies it through the window element */
|
70 |
+
var createInstance = function createInstance(classObj, options) {
|
71 |
+
var event;
|
72 |
+
var eventString = "LazyLoad::Initialized";
|
73 |
+
var instance = new classObj(options);
|
74 |
+
try {
|
75 |
+
// Works in modern browsers
|
76 |
+
event = new CustomEvent(eventString, { detail: { instance: instance } });
|
77 |
+
} catch (err) {
|
78 |
+
// Works in Internet Explorer (all versions)
|
79 |
+
event = document.createEvent("CustomEvent");
|
80 |
+
event.initCustomEvent(eventString, false, false, { instance: instance });
|
81 |
+
}
|
82 |
+
window.dispatchEvent(event);
|
83 |
+
};
|
84 |
+
|
85 |
+
/* Auto initialization of one or more instances of lazyload, depending on the
|
86 |
+
options passed in (plain object or an array) */
|
87 |
+
var autoInitialize = function autoInitialize(classObj, options) {
|
88 |
+
var optsLength = options.length;
|
89 |
+
if (!optsLength) {
|
90 |
+
// Plain object
|
91 |
+
createInstance(classObj, options);
|
92 |
+
} else {
|
93 |
+
// Array of objects
|
94 |
+
for (var i = 0; i < optsLength; i++) {
|
95 |
+
createInstance(classObj, options[i]);
|
96 |
+
}
|
97 |
+
}
|
98 |
+
};
|
99 |
+
|
100 |
+
var dataPrefix = "data-";
|
101 |
+
|
102 |
+
var getData = function getData(element, attribute) {
|
103 |
+
return element.getAttribute(dataPrefix + attribute);
|
104 |
+
};
|
105 |
+
|
106 |
+
var setData = function setData(element, attribute, value) {
|
107 |
+
return element.setAttribute(dataPrefix + attribute, value);
|
108 |
+
};
|
109 |
+
|
110 |
+
var setSourcesForPicture = function setSourcesForPicture(element, srcsetDataAttribute) {
|
111 |
+
var parent = element.parentNode;
|
112 |
+
if (parent.tagName !== "PICTURE") {
|
113 |
+
return;
|
114 |
+
}
|
115 |
+
for (var i = 0; i < parent.children.length; i++) {
|
116 |
+
var pictureChild = parent.children[i];
|
117 |
+
if (pictureChild.tagName === "SOURCE") {
|
118 |
+
var sourceSrcset = getData(pictureChild, srcsetDataAttribute);
|
119 |
+
if (sourceSrcset) {
|
120 |
+
pictureChild.setAttribute("srcset", sourceSrcset);
|
121 |
+
}
|
122 |
+
}
|
123 |
+
}
|
124 |
+
};
|
125 |
+
|
126 |
+
var setSources = function setSources(element, srcsetDataAttribute, srcDataAttribute) {
|
127 |
+
var tagName = element.tagName;
|
128 |
+
var elementSrc = getData(element, srcDataAttribute);
|
129 |
+
if (tagName === "IMG") {
|
130 |
+
setSourcesForPicture(element, srcsetDataAttribute);
|
131 |
+
var imgSrcset = getData(element, srcsetDataAttribute);
|
132 |
+
if (imgSrcset) {
|
133 |
+
element.setAttribute("srcset", imgSrcset);
|
134 |
+
}
|
135 |
+
if (elementSrc) {
|
136 |
+
element.setAttribute("src", elementSrc);
|
137 |
+
}
|
138 |
+
return;
|
139 |
+
}
|
140 |
+
if (tagName === "IFRAME") {
|
141 |
+
if (elementSrc) {
|
142 |
+
element.setAttribute("src", elementSrc);
|
143 |
+
}
|
144 |
+
return;
|
145 |
+
}
|
146 |
+
if (elementSrc) {
|
147 |
+
element.style.backgroundImage = 'url("' + elementSrc + '")';
|
148 |
+
}
|
149 |
+
};
|
150 |
+
|
151 |
+
var supportsClassList = "classList" in document.createElement("p");
|
152 |
+
|
153 |
+
var addClass = function addClass(element, className) {
|
154 |
+
if (supportsClassList) {
|
155 |
+
element.classList.add(className);
|
156 |
+
return;
|
157 |
+
}
|
158 |
+
element.className += (element.className ? " " : "") + className;
|
159 |
+
};
|
160 |
+
|
161 |
+
var removeClass = function removeClass(element, className) {
|
162 |
+
if (supportsClassList) {
|
163 |
+
element.classList.remove(className);
|
164 |
+
return;
|
165 |
+
}
|
166 |
+
element.className = element.className.replace(new RegExp("(^|\\s+)" + className + "(\\s+|$)"), " ").replace(/^\s+/, "").replace(/\s+$/, "");
|
167 |
+
};
|
168 |
+
|
169 |
+
/*
|
170 |
+
* Constructor
|
171 |
+
*/
|
172 |
+
|
173 |
+
var LazyLoad = function LazyLoad(instanceSettings) {
|
174 |
+
this._settings = _extends({}, defaultSettings, instanceSettings);
|
175 |
+
this._queryOriginNode = this._settings.container === window ? document : this._settings.container;
|
176 |
+
|
177 |
+
this._previousLoopTime = 0;
|
178 |
+
this._loopTimeout = null;
|
179 |
+
this._boundHandleScroll = this.handleScroll.bind(this);
|
180 |
+
|
181 |
+
this._isFirstLoop = true;
|
182 |
+
window.addEventListener("resize", this._boundHandleScroll);
|
183 |
+
this.update();
|
184 |
+
};
|
185 |
+
|
186 |
+
LazyLoad.prototype = {
|
187 |
+
|
188 |
+
/*
|
189 |
+
* Private methods
|
190 |
+
*/
|
191 |
+
|
192 |
+
_reveal: function _reveal(element) {
|
193 |
+
var settings = this._settings;
|
194 |
+
|
195 |
+
var errorCallback = function errorCallback() {
|
196 |
+
/* As this method is asynchronous, it must be protected against external destroy() calls */
|
197 |
+
if (!settings) {
|
198 |
+
return;
|
199 |
+
}
|
200 |
+
element.removeEventListener("load", loadCallback);
|
201 |
+
element.removeEventListener("error", errorCallback);
|
202 |
+
removeClass(element, settings.class_loading);
|
203 |
+
addClass(element, settings.class_error);
|
204 |
+
callCallback(settings.callback_error, element);
|
205 |
+
};
|
206 |
+
|
207 |
+
var loadCallback = function loadCallback() {
|
208 |
+
/* As this method is asynchronous, it must be protected against external destroy() calls */
|
209 |
+
if (!settings) {
|
210 |
+
return;
|
211 |
+
}
|
212 |
+
removeClass(element, settings.class_loading);
|
213 |
+
addClass(element, settings.class_loaded);
|
214 |
+
element.removeEventListener("load", loadCallback);
|
215 |
+
element.removeEventListener("error", errorCallback);
|
216 |
+
/* Calling LOAD callback */
|
217 |
+
callCallback(settings.callback_load, element);
|
218 |
+
};
|
219 |
+
|
220 |
+
if (element.tagName === "IMG" || element.tagName === "IFRAME") {
|
221 |
+
element.addEventListener("load", loadCallback);
|
222 |
+
element.addEventListener("error", errorCallback);
|
223 |
+
addClass(element, settings.class_loading);
|
224 |
+
}
|
225 |
+
|
226 |
+
setSources(element, settings.data_srcset, settings.data_src);
|
227 |
+
/* Calling SET callback */
|
228 |
+
callCallback(settings.callback_set, element);
|
229 |
+
},
|
230 |
+
|
231 |
+
_loopThroughElements: function _loopThroughElements() {
|
232 |
+
var settings = this._settings,
|
233 |
+
elements = this._elements,
|
234 |
+
elementsLength = !elements ? 0 : elements.length;
|
235 |
+
var i = void 0,
|
236 |
+
processedIndexes = [],
|
237 |
+
firstLoop = this._isFirstLoop;
|
238 |
+
|
239 |
+
for (i = 0; i < elementsLength; i++) {
|
240 |
+
var element = elements[i];
|
241 |
+
/* If must skip_invisible and element is invisible, skip it */
|
242 |
+
if (settings.skip_invisible && element.offsetParent === null) {
|
243 |
+
continue;
|
244 |
+
}
|
245 |
+
|
246 |
+
if (isBot || isInsideViewport(element, settings.container, settings.threshold)) {
|
247 |
+
if (firstLoop) {
|
248 |
+
addClass(element, settings.class_initial);
|
249 |
+
}
|
250 |
+
/* Start loading the image */
|
251 |
+
this._reveal(element);
|
252 |
+
/* Marking the element as processed. */
|
253 |
+
processedIndexes.push(i);
|
254 |
+
setData(element, "was-processed", true);
|
255 |
+
}
|
256 |
+
}
|
257 |
+
/* Removing processed elements from this._elements. */
|
258 |
+
while (processedIndexes.length) {
|
259 |
+
elements.splice(processedIndexes.pop(), 1);
|
260 |
+
/* Calling the end loop callback */
|
261 |
+
callCallback(settings.callback_processed, elements.length);
|
262 |
+
}
|
263 |
+
/* Stop listening to scroll event when 0 elements remains */
|
264 |
+
if (elementsLength === 0) {
|
265 |
+
this._stopScrollHandler();
|
266 |
+
}
|
267 |
+
/* Sets isFirstLoop to false */
|
268 |
+
if (firstLoop) {
|
269 |
+
this._isFirstLoop = false;
|
270 |
+
}
|
271 |
+
},
|
272 |
+
|
273 |
+
_purgeElements: function _purgeElements() {
|
274 |
+
var elements = this._elements,
|
275 |
+
elementsLength = elements.length;
|
276 |
+
var i = void 0,
|
277 |
+
elementsToPurge = [];
|
278 |
+
|
279 |
+
for (i = 0; i < elementsLength; i++) {
|
280 |
+
var element = elements[i];
|
281 |
+
/* If the element has already been processed, skip it */
|
282 |
+
if (getData(element, "was-processed")) {
|
283 |
+
elementsToPurge.push(i);
|
284 |
+
}
|
285 |
+
}
|
286 |
+
/* Removing elements to purge from this._elements. */
|
287 |
+
while (elementsToPurge.length > 0) {
|
288 |
+
elements.splice(elementsToPurge.pop(), 1);
|
289 |
+
}
|
290 |
+
},
|
291 |
+
|
292 |
+
_startScrollHandler: function _startScrollHandler() {
|
293 |
+
if (!this._isHandlingScroll) {
|
294 |
+
this._isHandlingScroll = true;
|
295 |
+
this._settings.container.addEventListener("scroll", this._boundHandleScroll);
|
296 |
+
}
|
297 |
+
},
|
298 |
+
|
299 |
+
_stopScrollHandler: function _stopScrollHandler() {
|
300 |
+
if (this._isHandlingScroll) {
|
301 |
+
this._isHandlingScroll = false;
|
302 |
+
this._settings.container.removeEventListener("scroll", this._boundHandleScroll);
|
303 |
+
}
|
304 |
+
},
|
305 |
+
|
306 |
+
/*
|
307 |
+
* Public methods
|
308 |
+
*/
|
309 |
+
|
310 |
+
handleScroll: function handleScroll() {
|
311 |
+
var throttle = this._settings.throttle;
|
312 |
+
|
313 |
+
if (throttle !== 0) {
|
314 |
+
var now = Date.now();
|
315 |
+
var remainingTime = throttle - (now - this._previousLoopTime);
|
316 |
+
if (remainingTime <= 0 || remainingTime > throttle) {
|
317 |
+
if (this._loopTimeout) {
|
318 |
+
clearTimeout(this._loopTimeout);
|
319 |
+
this._loopTimeout = null;
|
320 |
+
}
|
321 |
+
this._previousLoopTime = now;
|
322 |
+
this._loopThroughElements();
|
323 |
+
} else if (!this._loopTimeout) {
|
324 |
+
this._loopTimeout = setTimeout(function () {
|
325 |
+
this._previousLoopTime = Date.now();
|
326 |
+
this._loopTimeout = null;
|
327 |
+
this._loopThroughElements();
|
328 |
+
}.bind(this), remainingTime);
|
329 |
+
}
|
330 |
+
} else {
|
331 |
+
this._loopThroughElements();
|
332 |
+
}
|
333 |
+
},
|
334 |
+
|
335 |
+
update: function update() {
|
336 |
+
// Converts to array the nodeset obtained querying the DOM from _queryOriginNode with elements_selector
|
337 |
+
this._elements = Array.prototype.slice.call(this._queryOriginNode.querySelectorAll(this._settings.elements_selector));
|
338 |
+
this._purgeElements();
|
339 |
+
this._loopThroughElements();
|
340 |
+
this._startScrollHandler();
|
341 |
+
},
|
342 |
+
|
343 |
+
destroy: function destroy() {
|
344 |
+
window.removeEventListener("resize", this._boundHandleScroll);
|
345 |
+
if (this._loopTimeout) {
|
346 |
+
clearTimeout(this._loopTimeout);
|
347 |
+
this._loopTimeout = null;
|
348 |
+
}
|
349 |
+
this._stopScrollHandler();
|
350 |
+
this._elements = null;
|
351 |
+
this._queryOriginNode = null;
|
352 |
+
this._settings = null;
|
353 |
+
}
|
354 |
+
};
|
355 |
+
|
356 |
+
/* Automatic instances creation if required (useful for async script loading!) */
|
357 |
+
var autoInitOptions = window.lazyLoadOptions;
|
358 |
+
if (autoInitOptions) {
|
359 |
+
autoInitialize(LazyLoad, autoInitOptions);
|
360 |
+
}
|
361 |
+
|
362 |
+
return LazyLoad;
|
363 |
+
});
|
assets/js/lazyload-8.5.2.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 e={elements_selector:"img",container:window,threshold:300,throttle:150,data_src:"src",data_srcset:"srcset",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},t=!("onscroll"in window)||/glebot/.test(navigator.userAgent),n=function(e,t){e&&e(t)},o=function(e){return e.getBoundingClientRect().top+window.pageYOffset-e.ownerDocument.documentElement.clientTop},i=function(e,t,n){return(t===window?window.innerHeight+window.pageYOffset:o(t)+t.offsetHeight)<=o(e)-n},s=function(e){return e.getBoundingClientRect().left+window.pageXOffset-e.ownerDocument.documentElement.clientLeft},r=function(e,t,n){var o=window.innerWidth;return(t===window?o+window.pageXOffset:s(t)+o)<=s(e)-n},l=function(e,t,n){return(t===window?window.pageYOffset:o(t))>=o(e)+n+e.offsetHeight},a=function(e,t,n){return(t===window?window.pageXOffset:s(t))>=s(e)+n+e.offsetWidth},c=function(e,t,n){return!(i(e,t,n)||l(e,t,n)||r(e,t,n)||a(e,t,n))},u=function(e,t){var n,o=new e(t);try{n=new CustomEvent("LazyLoad::Initialized",{detail:{instance:o}})}catch(e){(n=document.createEvent("CustomEvent")).initCustomEvent("LazyLoad::Initialized",!1,!1,{instance:o})}window.dispatchEvent(n)},d=function(e,t){return e.getAttribute("data-"+t)},h=function(e,t,n){return e.setAttribute("data-"+t,n)},f=function(e,t){var n=e.parentNode;if("PICTURE"===n.tagName)for(var o=0;o<n.children.length;o++){var i=n.children[o];if("SOURCE"===i.tagName){var s=d(i,t);s&&i.setAttribute("srcset",s)}}},_=function(e,t,n){var o=e.tagName,i=d(e,n);if("IMG"===o){f(e,t);var s=d(e,t);return s&&e.setAttribute("srcset",s),void(i&&e.setAttribute("src",i))}"IFRAME"!==o?i&&(e.style.backgroundImage='url("'+i+'")'):i&&e.setAttribute("src",i)},p="classList"in document.createElement("p"),m=function(e,t){p?e.classList.add(t):e.className+=(e.className?" ":"")+t},g=function(e,t){p?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\s+)"+t+"(\\s+|$)")," ").replace(/^\s+/,"").replace(/\s+$/,"")},v=function(t){this._settings=_extends({},e,t),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()};v.prototype={_reveal:function(e){var t=this._settings,o=function o(){t&&(e.removeEventListener("load",i),e.removeEventListener("error",o),g(e,t.class_loading),m(e,t.class_error),n(t.callback_error,e))},i=function i(){t&&(g(e,t.class_loading),m(e,t.class_loaded),e.removeEventListener("load",i),e.removeEventListener("error",o),n(t.callback_load,e))};"IMG"!==e.tagName&&"IFRAME"!==e.tagName||(e.addEventListener("load",i),e.addEventListener("error",o),m(e,t.class_loading)),_(e,t.data_srcset,t.data_src),n(t.callback_set,e)},_loopThroughElements:function(){var e=this._settings,o=this._elements,i=o?o.length:0,s=void 0,r=[],l=this._isFirstLoop;for(s=0;s<i;s++){var a=o[s];e.skip_invisible&&null===a.offsetParent||(t||c(a,e.container,e.threshold))&&(l&&m(a,e.class_initial),this._reveal(a),r.push(s),h(a,"was-processed",!0))}for(;r.length;)o.splice(r.pop(),1),n(e.callback_processed,o.length);0===i&&this._stopScrollHandler(),l&&(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];d(i,"was-processed")&&o.push(n)}for(;o.length>0;)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||n>e?(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()},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}};var w=window.lazyLoadOptions;return w&&function(e,t){var n=t.length;if(n)for(var o=0;o<n;o++)u(e,t[o]);else u(e,t)}(v,w),v});
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: creativejuiz, tabrisrp, wp_media
|
3 |
Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
|
4 |
Requires at least: 3.0
|
5 |
-
Tested up to: 4.
|
6 |
Requires PHP: 5.3
|
7 |
-
Stable tag: 1.4.
|
8 |
|
9 |
The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
|
10 |
|
@@ -64,6 +64,9 @@ 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 |
|
68 |
= 1.4.5 =
|
69 |
* Rename Setting Page Name in WP Menu
|
2 |
Contributors: creativejuiz, tabrisrp, wp_media
|
3 |
Tags: lazyload, lazy load, images, iframes, thumbnail, thumbnails, smiley, smilies, avatar, gravatar
|
4 |
Requires at least: 3.0
|
5 |
+
Tested up to: 4.8
|
6 |
Requires PHP: 5.3
|
7 |
+
Stable tag: 1.4.6
|
8 |
|
9 |
The tiny Lazy Load script for WordPress without jQuery, works for images and iframes.
|
10 |
|
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.6 =
|
68 |
+
* Correctly include version 8.5.2 of lazyload script
|
69 |
+
* Prevent 404 error on lazyload script if URL contains "-v"
|
70 |
|
71 |
= 1.4.5 =
|
72 |
* Rename Setting Page Name in WP Menu
|
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.
|
7 |
* Author: WP Media
|
8 |
* Author URI: https://wp-rocket.me
|
9 |
* Text Domain: rocket-lazy-load
|
@@ -26,7 +26,7 @@
|
|
26 |
*/
|
27 |
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
|
28 |
|
29 |
-
define( 'ROCKET_LL_VERSION', '1.4.
|
30 |
define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
|
31 |
define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
|
32 |
define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
|
@@ -122,7 +122,7 @@ function rocket_lazyload_script() {
|
|
122 |
var s = d.createElement("script"); s.async = true;
|
123 |
var v = !("IntersectionObserver" in w) ? "8.5.2" : "10.3.5";
|
124 |
s.src = "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-v' . $suffix . '.js";
|
125 |
-
s.src = s.src.replace( "-v", "-" + v );
|
126 |
w.lazyLoadOptions = {
|
127 |
elements_selector: "img, iframe",
|
128 |
data_src: "lazy-src",
|
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.6
|
7 |
* Author: WP Media
|
8 |
* Author URI: https://wp-rocket.me
|
9 |
* Text Domain: rocket-lazy-load
|
26 |
*/
|
27 |
defined( 'ABSPATH' ) || die( 'Cheatin\' uh?' );
|
28 |
|
29 |
+
define( 'ROCKET_LL_VERSION', '1.4.6' );
|
30 |
define( 'ROCKET_LL_PATH', realpath( plugin_dir_path( __FILE__ ) ) . '/' );
|
31 |
define( 'ROCKET_LL_3RD_PARTY_PATH', ROCKET_LL_PATH . '3rd-party/' );
|
32 |
define( 'ROCKET_LL_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets/' );
|
122 |
var s = d.createElement("script"); s.async = true;
|
123 |
var v = !("IntersectionObserver" in w) ? "8.5.2" : "10.3.5";
|
124 |
s.src = "' . ROCKET_LL_FRONT_JS_URL . 'lazyload-v' . $suffix . '.js";
|
125 |
+
s.src = s.src.replace( "lazyload-v", "lazyload-" + v );
|
126 |
w.lazyLoadOptions = {
|
127 |
elements_selector: "img, iframe",
|
128 |
data_src: "lazy-src",
|