admin管理员组文章数量:1344225
The ResizeObserver has an observe() method and an unobserve() method. This seems to encourage having one ResizeObserver instance and observing and unobserving different elements as needed with logic in the callback to handle each entity. Is there any performance implications of doing this vs instantiating multiple ResizeObservers for observing different elements or groups of elements?
The ResizeObserver has an observe() method and an unobserve() method. This seems to encourage having one ResizeObserver instance and observing and unobserving different elements as needed with logic in the callback to handle each entity. Is there any performance implications of doing this vs instantiating multiple ResizeObservers for observing different elements or groups of elements?
Share Improve this question asked Jul 25, 2018 at 23:18 Wilhelmina LohanWilhelmina Lohan 3,0433 gold badges32 silver badges65 bronze badges 2- the unobserve method isn't encouraging reuse of a resize observer. It's a neccesity to allow proper garbage collection of listeners and elements – bryan60 Commented Jul 25, 2018 at 23:43
-
Like the
MutationObserver
,disconnect()
can be used for garbage collection. – Wilhelmina Lohan Commented Jul 26, 2018 at 14:55
1 Answer
Reset to default 11Looks like reusing (one) the ResizeObserver is preferred and more preformant:
https://github./WICG/ResizeObserver/issues/59#issuement-408098151 https://groups.google./a/chromium/forum/#!msg/blink-dev/z6ienONUb5A/F5-VcUZtBAAJ
本文标签: javascriptResizeObserver one vs multiple performanceStack Overflow
版权声明:本文标题:javascript - ResizeObserver one vs multiple performance - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743721985a2527726.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论