I am using the LazyLoad library at github.com/tuupola/lazyload which works great if you have the body as the root to detect images that come into the viewport.
However, I have a DIV with fixed width and height, actually covering the entire visible browser window. And I need to have lazyload assigned to this DIV, so when the DIV is scrolled, lazy load loads the images inside this DIV, that are coming into the viewport.
With the LazyLoad library it is possible to pass another root:
new LazyLoad(images, {
root: document.querySelector('#wrapper'),
});
In my JQuery code I specifically use:
$('img.lazyload').lazyload({
effect: 'fadeIn',
root: $('#wrapper'),
});
But it does not work. Neither with root: $('#wrapper')[0],
I also reported this at github/lazyload but maybe it is not a bug with the library, however, has to do with the Intersection Observer API?

As of writing this answer lazy loading images is supported by all browsers out of the box, even on android and ios browsers. You do not need to use any third party plugins to achieve the same.
All you need to do is add the attribute
loading="lazy"on yourimgtags just like below:Browser support:
You can find more details here:
MDN lazy loading
web.dev image lazy loading
MDN image loading attribute