neefrehman / lzy

The tiniest lazy loader for images - written in vanilla JS with no dependencies

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pretty please make default root Margin 0

mylescc opened this issue · comments

Hi there,

Long term fan here.

Just wondering if you could make the default root margin 0 rather than 200px x 200px. Wouldn't that make more sense?

Yours,

TRIBE

Also aligns with default options expected from IntersectionObserver.

Big fan. First time caller.

Sorry, @neefrehman – where is this feature? I've been waiting for ages!

Hi @mylescc @adamduncan, thanks for reaching out.

I'll be keeping the default root margin value as 200px. This script is for lazy loading images as they approach the viewport, so a non-zero root margin value will give some time for the image to load, which provides a better user experience as there won't be many blank spots on the page (provided a normal scrolling speed and well-optimised images). Obviously to do it in this way It will have to stray from the default option for IntersectionObserver.

Most other lazy-loading scripts have a similar approach (rightly so, I feel).

If you'd prefer to use a value of 0 then you can set that when calling lzy, as I've explained in the readme, or you can also hardcode the default value in the lzy.js file, if you feel you're up to it.

Marking this issue as closed.