[whatwg/dom] MutationOvserver and DOMNodeInsertedIntoDocument (Issue #1227)

I would like to share my recent observations and experiences working with **MutationObserver**. In my projects, I often encounter the need to track changes in the **DOM** to respond to the addition of elements. As you probably know, there is no way to get Node sizes before its added to DOM. 

The MutationObserver tool was introduced in the **DOM** standard as a more modern replacement for the **DOMNodeInsertedIntoDocument** event, and it provides powerful capabilities for monitoring DOM changes. However, in some cases, when we have multiple classes or modules that independently add elements to the screen and need to run MutationObserver to track DOM changes, I have found that this can significantly impact performance.

I understand that **MutationObserver** remains an important tool for more complex cases of monitoring changes, but in some situations, simpler alternatives could also be beneficial.

Considering this, I would like to suggest paying attention to the need for straightforward and efficient alternatives for tracking the addition of elements to the DOM, which could reduce the performance load. For example, using events and delegating them to a parent element might be a more efficient approach in certain scenarios.

I understand that MutationObserver offers flexibility and granularity in monitoring changes, but I believe it has its limitations in terms of performance, especially when dealing with a large number of elements.

Thank you for your attention, and I hope that the community can share their thoughts and experiences on this matter. Together, we can find optimal ways to work with DOM changes, considering both functionality and performance.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/dom/issues/1227
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/dom/issues/1227@github.com>

Received on Wednesday, 27 September 2023 06:58:11 UTC