You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
constimgTargets=document.querySelectorAll('img[data-src]');// only select the images with `data-src` attributeconstloadImg=function(entries,observer){const[entry]=entries;if(!entry.isIntersecting)return;// Replace src with data-srcentry.target.src=entry.target.dataset.src;entry.target.addEventListener('load',function(){entry.target.classList.remove('lazy-img');});observer.unobserve(entry.target);};constimgObserver=newIntersectionObserver(loadImg,{root: null,threshold: 0,rootMargin: '200px',// load image before we enter the viewport so that we don't have to wait});imgTargets.forEach(img=>imgObserver.observe(img));