Sha256: 7e886ac614a96b8428c4058fe1949adcc90a592a725a5bd6d7bef76ec6490f21

Contents?: true

Size: 472 Bytes

Versions: 10

Compression:

Stored size: 472 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">
const imageList = document.querySelectorAll('img[data-src]'); // Our lazyloading images use a data-src to hold the actual image source.

function lazyLoad() {
  for (const img of imageList) {
    img.src = img.getAttribute('data-src');
    img.onload = () => img.removeAttribute('data-src');
  }
}
export default lazyLoad;

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
landing-page-gem-1.2.9 assets/js/src/lazyLoad.js
landing-page-gem-1.2.8 assets/js/src/lazyLoad.js
landing-page-gem-1.2.7 assets/js/src/lazyLoad.js
landing-page-gem-1.2.6 assets/js/src/lazyLoad.js
landing-page-gem-1.2.5 assets/js/src/lazyLoad.js
landing-page-gem-1.2.4 assets/js/src/lazyLoad.js
landing-page-gem-1.2.3 assets/js/src/lazyLoad.js
landing-page-gem-1.2.2 assets/js/src/lazyLoad.js
landing-page-gem-1.2.1 assets/js/src/lazyLoad.js
landing-page-gem-1.2.0 assets/js/src/lazyLoad.js