[object Object]

← back to Jim Gravity

Remove no-op img.src self-assignment from lazy-load block

f47de3a6a61cbe99f5f4e583a86e266d23c01219 · 2026-05-18 20:10:36 -0700 · Steve Abrams

Files touched

Diff

commit f47de3a6a61cbe99f5f4e583a86e266d23c01219
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Mon May 18 20:10:36 2026 -0700

    Remove no-op img.src self-assignment from lazy-load block
---
 index.html | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/index.html b/index.html
index 9c8ca31..89fd6e7 100644
--- a/index.html
+++ b/index.html
@@ -602,13 +602,9 @@
         });
         
         // Lazy load images optimization
-        if ('loading' in HTMLImageElement.prototype) {
-            const images = document.querySelectorAll('img[loading="lazy"]');
-            images.forEach(img => {
-                img.src = img.src;
-            });
-        } else {
-            // Fallback for browsers that don't support lazy loading
+        // Native lazy loading works via the loading="lazy" attribute already;
+        // only load the lazysizes polyfill for browsers that lack it.
+        if (!('loading' in HTMLImageElement.prototype)) {
             const script = document.createElement('script');
             script.src = 'https://cdnjs.cloudflare.com/ajax/libs/lazysizes/5.3.2/lazysizes.min.js';
             document.body.appendChild(script);

← 7b36357 Harden external links with rel=noopener noreferrer  ·  back to Jim Gravity  ·  (newest)