const useLazyLoading = () => { const imgs = document.querySelectorAll('.lazy'); const observerCallback = (entries, observer) => { entries.forEach(({ isIntersecting, intersectionRatio, target }) => { if (isIntersecting && intersectionRatio > 0) { target.src = target.dataset.src; target.classList.remove("lazy"); observer.unobserve(target); } }); }; const io = new IntersectionObserver(observerCallback); imgs.forEach((img) => io.observe(img)); };