import Hunt from 'huntjs';
// lazy loading images using dataset and hunt
const lazyImages = document.querySelectorAll('img.lazy');
let observer = new Hunt(lazyImages, {
enter: (image) => image.src = image.dataset.src
});
Minimal library to observe nodes entering and leaving the viewport. Library written by Jeremias Menichelli and contributors.
Example of code lazy loading images when they become visible.
import Hunt from 'huntjs';
// lazy loading images using dataset and hunt
const lazyImages = document.querySelectorAll('img.lazy');
let observer = new Hunt(lazyImages, {
enter: (image) => image.src = image.dataset.src
});