Sha256: a597d5f31c2a85a5b2a666a2ca060cadc3cf0e76a929f6c014712e7e18200f02
Contents?: true
Size: 448 Bytes
Versions: 17
Compression:
Stored size: 448 Bytes
Contents
// Lazy load images // ex. <img src="/path/to/small-placeholder_image.png" data-src="/path/to/actual_image.jpg" alt="You better not leave it blank"> function lazyLoad() { const lazyLoadImages = document.querySelectorAll('img[data-src]'); [...lazyLoadImages].forEach(img => { img.setAttribute('src', img.getAttribute('data-src')); img.onload = function() { img.removeAttribute('data-src'); }; }); } export default lazyLoad;
Version data entries
17 entries across 17 versions & 1 rubygems