Lazy load all the images
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Hamcha 2020-06-21 20:03:41 +02:00
parent e700bb9c30
commit 389a5b33d0
Signed by: hamcha
GPG Key ID: 41467804B19A3315
1 changed files with 6 additions and 1 deletions

View File

@ -4,7 +4,7 @@ import { findParent } from "./utils";
// This is used for cache busting when userscript changes significantly.
// Only change it when you made changes to the processHTML part!
export const CURRENT_VERSION = "df914edcb5522670309ceb8dfd0195dc70fb81d4";
export const CURRENT_VERSION = "e700bb9c309627b944618152a7d8e936ae7a05db";
function chemistryFixups(root: HTMLElement) {
// Enable page-specific CSS rules
@ -147,6 +147,11 @@ export function processHTML(root: HTMLElement, docname: string): void {
header.appendChild(document.createTextNode(docname.replace(/_/g, " ")));
root.insertBefore(header, root.firstChild);
// Lazy load all images
root
.querySelectorAll<HTMLImageElement>("img")
.forEach((elem) => elem.setAttribute("loading", "lazy"));
// Remove edit links
root.querySelectorAll(".mw-editsection").forEach((editLink) => {
editLink.parentElement.removeChild(editLink);