wp_back/wp-content/plugins/debloat/inc/delay-load/js/defer-load.js

36 lines
969 B
JavaScript
Raw Normal View History

2024-05-20 15:37:46 +03:00
/**
* Debloat plugin's defer load.
* @preserve
* @copyright asadkn 2021
*/
"use strict";
(() => {
const n = true;
const e = [ ...document.querySelectorAll("script[defer]") ];
if (e.length && document.readyState !== "complete") {
let t = document.readyState;
Object.defineProperty(document, "readyState", {
configurable: true,
get() {
return t;
},
set(e) {
return t = e;
}
});
let e = false;
document.addEventListener("DOMContentLoaded", () => {
t = "interactive";
n && console.log("DCL Ready.");
e = true;
document.dispatchEvent(new Event("readystatechange"));
e = false;
});
document.addEventListener("readystatechange", () => {
if (!e && t === "interactive") {
t = "complete";
}
});
}
})();