Feature-detect: mutation-event availability in JavaScript?
How can my JavaScript detect if an event is available? I'm aware of some great event-compatibility tables , but I need to use feature detection, not browser-sniffing plus a lookup table. Specifically, my JS makes great use of the DOM mutation events ( DOMNodeInserted and DOMSubtreeModified ) -- which work great in all browsers except (of course) Internet Explorer. So, how would I detect if a browser supports DOMNodeInserted ? If you just want to check if the browser supports mutation events in general, you can use this simple test: var hasMutationEvents = ("MutationEvent" in window); Here are