CSS, Lazy Loading, JavaScript, Tutorial, Javascript Tips.
img.src = lazy.src; img.style.paddingTop = 0; img.classList.remove('loading'); img.classList.add('loaded'); } // Wait for some kind of event. In this example I'm using "window.load" window.addEventListener('load', function() { img.classList.add('loading'); lazy.src = img.getAttribute('data-src');