In whatwg/html#5510 I'm trying to specify <img loading=lazy> in terms of IntersectionObserver as per discussion in whatwg/html#5236
The desired behavior for lazy-loading is to dynamically change the rootMargin in response to things like scrolling and network changes. See whatwg/html#5408 (comment)
Since IntersectionObserver only allows setting the rootMargin upon initialization, this would require one of
- Register a new
IntersectionObserver and observe all the same elements as the old one, and get rid of the old one. This seems bad, but I assume is what a JS polyfill would have to do?
- Have the browser internally update the
rootMargin even though the public API doesn't allow for it.
I think the second option seems better, but per the extensible web manifesto we try to have web features be explained by lower-level APIs without having special magic that isn't accessible to web developers.
Are there issues with modifying the rootMargin after initialization?
In whatwg/html#5510 I'm trying to specify
<img loading=lazy>in terms of IntersectionObserver as per discussion in whatwg/html#5236The desired behavior for lazy-loading is to dynamically change the
rootMarginin response to things like scrolling and network changes. See whatwg/html#5408 (comment)Since
IntersectionObserveronly allows setting therootMarginupon initialization, this would require one ofIntersectionObserverand observe all the same elements as the old one, and get rid of the old one. This seems bad, but I assume is what a JS polyfill would have to do?rootMargineven though the public API doesn't allow for it.I think the second option seems better, but per the extensible web manifesto we try to have web features be explained by lower-level APIs without having special magic that isn't accessible to web developers.
Are there issues with modifying the
rootMarginafter initialization?