document.addEventListener('DOMContentLoaded', function() { var lazyLoadImages = document.querySelectorAll('.lazyload'); var observer = new IntersectionObserver(function(entries) { entries.forEach(function(entry) { if (entry.isIntersecting) { var img = entry.target; img.src = img.dataset.src; img.classList.remove('lazyload'); observer.unobserve(img); } }); }); lazyLoadImages.forEach(function(img) { observer.observe(img); }); });