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 237 forks source link

Detached DOM images get loaded when they shouldn't #229

Open grololo06 opened 4 years ago

grololo06 commented 4 years ago

Hi, We (https://github.com/oceanomics/ecotaxa_dev) reload part of a page using JQuery elem.html() with the output of an Ajax call. This part of the page contains up to 1000 images, so of course we use Lazy to load them only when needed. We saw that, after reload, the (then detached) old DOM continued to trigger image loads from server. The main cause being that _isInLoadableArea() always returns true for detached elements (getBoundingClientRect() returns 0 for all properties). We chose to cure the problem by issuing proper .destroy()calls before DOM patching but I leave this issue here for the records, in case it helps someone.

dkern commented 4 years ago

Bit of an edge case but intresting. Maybe an additional check could solve this issue, but i'm not sure if i want to add those overhead to all instances ...