Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MutationOvserver and DOMNodeInsertedIntoDocument #1227

Open
kokins opened this issue Sep 27, 2023 · 1 comment
Open

MutationOvserver and DOMNodeInsertedIntoDocument #1227

kokins opened this issue Sep 27, 2023 · 1 comment

Comments

@kokins
Copy link

kokins commented Sep 27, 2023

I would like to share my recent observations and experiences working with MutationObserver. In my projects, I often encounter the need to track changes 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.

@annevk
Copy link
Member

annevk commented Sep 27, 2023

Would #885 address your issues? It seems I volunteered to take that forward and then dropped the ball...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants