Is it still necessary to throttle $(window).scroll()?
browser, dom, javascript, jquery
Solution
The throttle reduces the number of events fired to 4 every second. Without throttling, it's possible for a significantly larger number of events to fire per second. 4 per second is easily detectable by the human eye (depending upon what you are doing).
As for whether you still need to throttle, it really depends on your clients. If you are dealing with a lot of older computers with bad graphics cards using IE6, high speed event firing will probably cause a lot of noticeable problems. It also depends on what your scroll event is actually doing (how long it takes to respond, whether it consumes memory and how fast it releases it, etc.)
Problem
There's an oft-cited blog post written by John Resig in January 2011 that advises against attaching handlers to the window scroll event. Instead, the common wisdom says to throttle your handler, for example: ``` $(window).scroll(_.throttle(myScrollHandler, 250)); ``` In my recent testing, the UI response is much smoother when the handler is attached directly to the scroll event. Throttling the handler causes a visible lag. Have modern browsers solved this problem? Is there any testing or browser compatibility data available?