Performance Benchmarks
pastelsky opened this issue · comments
Implementation looks very interesting, especially the use of MutationObserver
. I was wondering how performant is the polyfill when MutationObserver is used, or dirty polling is used.
The existing best practice for lazy loading of images includes attaching a single debounced window scroll listener and using getBoundingClientRect
check if images are in viewport, but is far from a full proof solution.
One may assume that since IntersectionObserver's are cheap, they could be added to observe each image (and disconnected after images are loaded / load failed). In this case, a person using this polyfill (or any other for that matter) would unknowingly attach a multiple scroll listeners which would harm performance rather than improve it.
It would be interesting to see the performance impact in such a case.