1const LazyLoading = (parameters) => { 2 const selector = parameters.selector || 'img'; 3 const attribute = parameters.attribute || 'data-src'; 4 5 const imgs = document.querySelectorAll(selector); 6 const observer = new IntersectionObserver((entries) => { 7 entries.forEach((entry) => { 8 if (entry.isIntersecting) { 9 const img = entry.target; 10 const attr = img.getAttribute(attribute); 11 if (attr !== null) { 12 img.src = attr; 13 } 14 observer.unobserve(img); 15 } 16 }); 17 }, { 18 root: null, 19 rootMargin: '0px', 20 threshold: [0] 21 }); 22 23 imgs.forEach((img) => { 24 observer.observe(img); 25 }); 26 27 return { 28 observer: observer, 29 imgs: imgs 30 }; 31};
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.