diff --git a/changedetectionio/blueprint/watchlist/templates/watch-overview.html b/changedetectionio/blueprint/watchlist/templates/watch-overview.html index 55e7a2726..133f2a06f 100644 --- a/changedetectionio/blueprint/watchlist/templates/watch-overview.html +++ b/changedetectionio/blueprint/watchlist/templates/watch-overview.html @@ -14,6 +14,46 @@ // Initialize Feather icons after the page loads document.addEventListener('DOMContentLoaded', function() { feather.replace(); + + // Intersection Observer for lazy loading favicons + // Only load favicon images when they enter the viewport + if ('IntersectionObserver' in window) { + const faviconObserver = new IntersectionObserver((entries, observer) => { + entries.forEach(entry => { + if (entry.isIntersecting) { + const img = entry.target; + const src = img.getAttribute('data-src'); + + if (src) { + // Load the actual favicon + img.src = src; + img.removeAttribute('data-src'); + } + + // Stop observing this image + observer.unobserve(img); + } + }); + }, { + // Start loading slightly before the image enters viewport + rootMargin: '50px', + threshold: 0.01 + }); + + // Observe all lazy favicon images + document.querySelectorAll('.lazy-favicon').forEach(img => { + faviconObserver.observe(img); + }); + } else { + // Fallback for older browsers: load all favicons immediately + document.querySelectorAll('.lazy-favicon').forEach(img => { + const src = img.getAttribute('data-src'); + if (src) { + img.src = src; + img.removeAttribute('data-src'); + } + }); + } });