Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I find all scroll listeners on my document/window object?

Tags:

javascript

I have put my website through a performance analysis tool, and it has come back saying that there are too many scroll listeners on the document/window object.

Is there a way of finding all my scroll listeners for my document/window object?

Something maybe along the lines of :

window.scroll.listeners
like image 578
Oliver Watkins Avatar asked Jan 20 '16 13:01

Oliver Watkins


People also ask

How to listen to the window scroll event in a Vue component?

We can listen to the window scroll event in a Vue.js component by calling the window.addEventListener method to listen to the scroll event on the browser window.

How to remove the handlescroll scroll event listener from a hook?

We call window.addEventListener with 'scroll' in the created hook to add the handleScroll scroll event listener when the component is mounted. And in the destroyed hook, we call window.renmoveListener to remove the handleScroll scroll event listener.

How to show scroll bars in word?

Show Scroll Bars in Word Scroll bars might be manually hidden. You can change this setting to show the scroll bars instead. 1 Click File > Options. 2 On the Advanced tab, scroll to the Display section. 3 Select Show horizontal scroll bar and Show vertical scroll bar, and then click OK. See More....

How do I show the scroll bar on a PDF file?

You can change this setting to show the scroll bars instead. Click File > Options. On the Advanced tab, scroll to the Display section. Select Show horizontal scroll bar and Show vertical scroll bar, and then click OK. Scroll bars might be set to automatically hide themselves.


1 Answers

If you just want to find them, you can use chrome dev tools.

Copied from answer below:

You can right click on the target element -> select "inspect element" Scroll down on the right side of the dev frame, at the bottom is 'event listeners'. Expand the tree to see what events are attached to the element. Not sure if this works for events that are handled through bubbling (I'm guessing not)

Chrome Dev Tools Listeners Tab

See How do I view events fired on an element in Chrome DevTools?

Also, you can programmatically do it in Chrome

getEventListeners(window)

See https://stackoverflow.com/a/16544813/227299 and https://developers.google.com/chrome-developer-tools/docs/commandline-api#geteventlistenersobject

like image 102
Juan Mendes Avatar answered Oct 13 '22 01:10

Juan Mendes