javascript - ResizeObserver one vs multiple performance - Stack Overflow

The ResizeObserver has an observe() method and an unobserve() method. This seems to encourage having on

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
Add a ment  | 

1 Answer 1

Reset to default 11

Looks 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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743721986a4495976.html

相关推荐

  • javascript - ResizeObserver one vs multiple performance - Stack Overflow

    The ResizeObserver has an observe() method and an unobserve() method. This seems to encourage having on

    7天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信