When using DOMSubtreeModified
I get multiple, sometimes 30+ events firing. Is it possible to ensure that my function is only called once regardless of DOMSubtreeModified
is fired?
The Mutation Events
are performance hogs which can't really be tamed well. Therefore, they have been deprecated over a year ago and should be used only when really needed.
You could use the new and shiny Mutation Observers
from DOM Level 4 (follow the links there!). Where DOMSubtreeModified
fired a thousand times, MutationObserver
fires only once with all the modifications contained and accessible.
Works for (as of 2012/06):
window.WebKitMutationObserver
)Other than that ... some hackish solution with removing the listener and scheduling to add it again in some time in future (a second or two) might be worth exploring.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With