From 01b63f7a8247fb40d5f09388d8bb1cc74c6ab0cf Mon Sep 17 00:00:00 2001 From: Kumi Date: Wed, 4 Dec 2024 14:45:54 +0100 Subject: [PATCH] feat: Enhances image loading with lazy loading Adds lazy loading attribute to images to improve page load performance and user experience by deferring the loading of images until they are in the viewport. Fixes #44. --- src/wikimore/app.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wikimore/app.py b/src/wikimore/app.py index 15558b3..ca43457 100644 --- a/src/wikimore/app.py +++ b/src/wikimore/app.py @@ -428,6 +428,9 @@ def wiki_article( for img in soup.find_all("img"): img["src"] = get_proxy_url(img["src"]) + # While we're at it, ensure that images are loaded lazily + img["loading"] = "lazy" + for source in soup.find_all("source"): source["src"] = get_proxy_url(source["src"])