Find event listeners for DOM element

Webkit-/Blink-based browsers (i.e. Chrome, Safari, etc.) provide a neat utility to find out if and which event listeners are attached to a DOM node: getEventListeners(). It can only be invoked from the JavaScript console in the dev tools, not from a script. The return value is a map giving a list of handlers for each event type.

getEventListeners($0)

Firefox doesn't provide this function in its Developer Tools but has a graphical interface for events in its DOM Inspector. There's a tag labelled "event" next to each DOM node that has some event listeners attached to it. Clicking them reveals more information and allows to open the handler function in the Debugger.


This article has been published on on my blog. Here's a list of all articles if you're interested in this kind of stuff.