How to Find All Event Listeners on Page

Please note that the function getEventListeners is provided by console and hence some browsers may not have it.

Idea is to traverse the all elements and find the events on each of them.

  .reduce(function(pre, dom){
    var evtObj = getEventListeners(dom)
    Object.keys(evtObj).forEach(function (evt) {
      if (typeof pre[evt] === 'undefined') {
        pre[evt] = 0
      pre[evt] += evtObj[evt].length
    return pre
}, {})

Output under Chrome Console

{load: 1, click: 16}

This small codes will give you type of events with numbers.

Worth Sharing?


Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>