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.


Array.from(document.querySelectorAll('*'))
  .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.

How to Find All Event Listeners on Page

2 thoughts on “How to Find All Event Listeners on Page

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top