Skip to content

MutationOvserver and DOMNodeInsertedIntoDocument #1227

Open
@kokins

Description

@kokins

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions