WICG / virtual-scroller

Other
2k stars 83 forks source link

Removing iframes from the DOM has unfortunate consequences #128

Closed domenic closed 5 years ago

domenic commented 6 years ago

Consider a virtual scroller containing items, every 10th one of which is an iframe. When that iframe falls out of the scroller's viewport, the iframe element will get removed from the DOM. Because of how iframes work, this will completely unload it. Similarly, if it scrolls back into view, the iframe will get reloaded from its src="" URL.

This isn't really acceptable behavior for a lot of use cases, e.g. ads or stateful widgets.

Some solution ideas:

kenchris commented 6 years ago

The demo with headers, also shows how you can handle elements so that they don't get removed.

rakina commented 5 years ago

Since the new approach (detailed in the newly-updated explainer) doesn't recycle/remove elements anymore, this should be a non-issue as the iframe would just stay where it was!