|
@@ -31,6 +31,7 @@
|
|
|
const BLOCK_COOKIES_END_EVENT = "single-file-block-cookies-end";
|
|
const BLOCK_COOKIES_END_EVENT = "single-file-block-cookies-end";
|
|
|
const BLOCK_STORAGE_START_EVENT = "single-file-block-storage-start";
|
|
const BLOCK_STORAGE_START_EVENT = "single-file-block-storage-start";
|
|
|
const BLOCK_STORAGE_END_EVENT = "single-file-block-storage-end";
|
|
const BLOCK_STORAGE_END_EVENT = "single-file-block-storage-end";
|
|
|
|
|
+ const LAZY_LOAD_ATTRIBUTE = "single-file-lazy-load";
|
|
|
const LOAD_IMAGE_EVENT = "single-file-load-image";
|
|
const LOAD_IMAGE_EVENT = "single-file-load-image";
|
|
|
const IMAGE_LOADED_EVENT = "single-file-image-loaded";
|
|
const IMAGE_LOADED_EVENT = "single-file-image-loaded";
|
|
|
const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
|
|
const NEW_FONT_FACE_EVENT = "single-file-new-font-face";
|
|
@@ -69,6 +70,10 @@
|
|
|
scrollingElement.__defineGetter__("clientWidth", () => scrollWidth);
|
|
scrollingElement.__defineGetter__("clientWidth", () => scrollWidth);
|
|
|
screen.__defineGetter__("height", () => scrollHeight);
|
|
screen.__defineGetter__("height", () => scrollHeight);
|
|
|
screen.__defineGetter__("width", () => scrollWidth);
|
|
screen.__defineGetter__("width", () => scrollWidth);
|
|
|
|
|
+ document.querySelectorAll("[loading=lazy]").forEach(element => {
|
|
|
|
|
+ element.loading = "eager";
|
|
|
|
|
+ element.setAttribute(LAZY_LOAD_ATTRIBUTE, "");
|
|
|
|
|
+ });
|
|
|
if (!window._singleFile_getBoundingClientRect) {
|
|
if (!window._singleFile_getBoundingClientRect) {
|
|
|
window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
window._singleFile_getBoundingClientRect = Element.prototype.getBoundingClientRect;
|
|
|
Element.prototype.getBoundingClientRect = function () {
|
|
Element.prototype.getBoundingClientRect = function () {
|
|
@@ -154,6 +159,10 @@
|
|
|
|
|
|
|
|
addEventListener.call(window, LOAD_DEFERRED_IMAGES_END_EVENT, () => {
|
|
addEventListener.call(window, LOAD_DEFERRED_IMAGES_END_EVENT, () => {
|
|
|
const scrollingElement = document.scrollingElement || document.documentElement;
|
|
const scrollingElement = document.scrollingElement || document.documentElement;
|
|
|
|
|
+ document.querySelectorAll("[" + LAZY_LOAD_ATTRIBUTE + "]").forEach(element => {
|
|
|
|
|
+ element.loading = "lazy";
|
|
|
|
|
+ element.removeAttribute(LAZY_LOAD_ATTRIBUTE);
|
|
|
|
|
+ });
|
|
|
delete scrollingElement.clientHeight;
|
|
delete scrollingElement.clientHeight;
|
|
|
delete scrollingElement.clientWidth;
|
|
delete scrollingElement.clientWidth;
|
|
|
delete screen.height;
|
|
delete screen.height;
|