1document.addEventListener("DOMContentLoaded", function () { 2 let lazyImages = document.querySelectorAll("img[fifu-lazy='1']"); 3 4 function setSizesAttribute(image) { 5 if (image.getAttribute('fifu-data-sizes') === 'auto') { 6 let width = image.getAttribute('width') || image.clientWidth; 7 image.setAttribute('sizes', `${width}px`); 8 } 9 } 10 11 if ("IntersectionObserver" in window) { 12 let lazyImageObserver = new IntersectionObserver(function (entries, observer) { 13 entries.forEach(function (entry) { 14 if (entry.isIntersecting) { 15 let lazyImage = entry.target; 16 lazyImage.src = lazyImage.getAttribute('fifu-data-src'); 17 lazyImage.srcset = lazyImage.getAttribute('fifu-data-srcset'); 18 setSizesAttribute(lazyImage); 19 lazyImage.removeAttribute('fifu-lazy'); 20 lazyImageObserver.unobserve(lazyImage); 21 } 22 }); 23 }); 24 25 lazyImages.forEach(function (lazyImage) { 26 lazyImageObserver.observe(lazyImage); 27 }); 28 } else { 29 // Fallback for browsers that do not support IntersectionObserver 30 let lazyLoadThrottleTimeout; 31 32 function debounce(func, wait) { 33 return function () { 34 clearTimeout(lazyLoadThrottleTimeout); 35 lazyLoadThrottleTimeout = setTimeout(func, wait); 36 }; 37 } 38 39 function lazyLoad() { 40 let scrollTop = window.scrollY; 41 lazyImages.forEach(function (img) { 42 if (img.offsetTop < (window.innerHeight + scrollTop)) { 43 img.src = img.getAttribute('fifu-data-src'); 44 img.srcset = img.getAttribute('fifu-data-srcset'); 45 setSizesAttribute(img); 46 img.removeAttribute('fifu-lazy'); 47 } 48 }); 49 lazyImages = Array.prototype.filter.call(lazyImages, function (img) { 50 return img.hasAttribute('fifu-lazy'); 51 }); 52 if (lazyImages.length == 0) { 53 document.removeEventListener("scroll", lazyLoadHandler); 54 window.removeEventListener("resize", lazyLoadHandler); 55 window.removeEventListener("orientationchange", lazyLoadHandler); 56 } 57 } 58 59 let lazyLoadHandler = debounce(lazyLoad, 20); 60 61 document.addEventListener("scroll", lazyLoadHandler); 62 window.addEventListener("resize", lazyLoadHandler); 63 window.addEventListener("orientationchange", lazyLoadHandler); 64 } 65}, {once: true});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.