lscache_wp icon indicating copy to clipboard operation
lscache_wp copied to clipboard

Allow changing "threshold" for lazy loading (images)

Open frzsombor opened this issue 7 months ago • 2 comments

I figured out that currently, the IntersectionObserver's threshold, which is used for lazy loading, is set to 300px by default. I wanted to increase this to something that matches other lazy loading libraries and actual Chrome settings and I found that it might be possible to override the setting by defining a window.lazyLoadOptions object.

However, this only works for the autoInitialize function, which is looking for elements with the default .lazy selector. But when setting up LazyLoader for images with the [data-lazyloaded] attribute here, the window.lazyLoadOptions is ignored, so there is no way to override the 300px threshold, which - in my case - sometimes a little too hard and small.

Is it possible to modify lazyload.init.js so that it also respects an existing window.lazyLoadOptions?

frzsombor avatar May 13 '25 23:05 frzsombor

Yes definitely we can do that. @timotei-litespeed can you give a hand?

hi-hai avatar May 14 '25 13:05 hi-hai

@frzsombor I looked into and I have a code ready. We are making some code changes and I am putting this on pause for next period

timotei-litespeed avatar May 20 '25 15:05 timotei-litespeed