refactor: Improve lazy loading for images in ZenThemesImporter.mjs

Optimize the lazy loading implementation for images in the ZenThemesImporter.mjs file. This refactor enhances the page load performance and improves the overall user experience.
This commit is contained in:
Mauro Balades 2024-08-20 01:11:09 +02:00
parent 1f27bc40cd
commit ea8b4c36dc

View file

@ -100,17 +100,18 @@ var gZenThemeImporter = new class {
insertStylesheet() {
if (IOUtils.exists(this.styleSheetPath)) {
const styleSheet = document.getElementById("zen-themes-stylesheet");
let styleSheet = document.getElementById("zen-themes-stylesheet");
if (!styleSheet) {
const styleSheet = document.createElementNS("http://www.w3.org/1999/xhtml", "html:link");
styleSheet = document.createElementNS("http://www.w3.org/1999/xhtml", "html:link");
styleSheet.id = "zen-themes-stylesheet";
styleSheet.setAttribute("rel", "stylesheet");
styleSheet.setAttribute("type", "text/css");
styleSheet.setAttribute("href", this.styleSheetURI.spec);
document.documentElement.appendChild(styleSheet);
} else {
// add a ?=timestamp to the URL to force a reload
styleSheet.href = this.styleSheetURI.spec + "?" + Date.now();
}
// add a ?=timestamp to the URL to force a reload
styleSheet.href = this.styleSheetURI.spec + "?" + Date.now();
}
}