zuk / jquery.inview

Remy Sharp's jQuery plugin adds a bindable 'inview' event for detecting when an element is scrolled into view.
http://remysharp.com/2009/01/26/element-in-view-event-plugin/
Other
277 stars 586 forks source link

Save event handlers #4

Closed RSO closed 11 years ago

RSO commented 11 years ago

I've changed the behaviour of the jquery.inview plugin so that handlers aren't directly bound to the scroll event (like proposed on http://ejohn.org/blog/learning-from-twitter/).

Quote:

It's a very, very, bad idea to attach handlers to the window scroll event. Depending upon the browser the scroll event can fire a lot and putting code in the scroll callback will slow down any attempts to scroll the page (not a good idea). Any performance degradation in the scroll handler(s) as a result will only compound the performance of scrolling overall. Instead it's much better to use some form of a timer to check every X milliseconds OR to attach a scroll event and only run your code after a delay (or even after a given number of executions - and then a delay).

zuk commented 11 years ago

Nice to see a good, clean pull request for a change. Thanks!