I\'m working on an Extension in Chrome, and I\'m wondering: what\'s the best way to find out when an element comes into existence? Using plain javascript, with an interval t
How about the insertionQuery library?
insertionQuery uses CSS Animation callbacks attached to the selector(s) specified to run a callback when an element is created. This method allows callbacks to be run whenever an element is created, not just the first time.
From github:
Non-dom-event way to catch nodes showing up. And it uses selectors.
It's not just for wider browser support, It can be better than DOMMutationObserver for certain things.
Why?
- Because DOM Events slow down the browser and insertionQuery doesn't
- Because DOM Mutation Observer has less browser support than insertionQuery
- Because with insertionQuery you can filter DOM changes using selectors without performance overhead!
Widespread support!
IE10+ and mostly anything else (including mobile)