dkern / jquery.lazy

A lightweight, fast, feature-rich, powerful and highly configurable delayed content, image and background lazy loading plugin for jQuery & Zepto.
http://jquery.eisbehr.de/lazy
Other
1.02k stars 236 forks source link

Slow image load handling #256

Closed ostapski closed 1 year ago

ostapski commented 2 years ago

There is a huge bottleneck in the code (v1.7.10 - line 471):

This happens on pages with large amount of images (3000+) hiding element forces partial page re-render ... slowing image handling almost to still stand (one image per/sec)

image

once commented out - 30-50 images could be loaded in a second without any other changes

dkern commented 2 years ago

That sounds more like wrong usage to me. Its unlikely that you have 3000 images in your viewport. But Lazy only handles the images in viewport. It sounds to me like your images don't have an initial size. Therefore the default size of your images is 0x0px. So on page load ALL your images fit in the viewport of the browser, so every image will be loaded at once what of course is not great. But I never had problems with large pages / galleries if the images had correct dimensions.