shichuan/javascript-patterns — Issue #21: jquery-patterns / window-scroll-event.html
Author: rusteater
Created: 2012-01-17 01:48:11+00:00
State: open

the whole point of not doing much in the scroll event handler is because it degrades performance. But there's no reason to have a constant timer running. You should be running it only when the user starts scrolling:

var scrollTimer;
$(window).scroll(function() {
scrollTimer && clearTimeout(scrollTimer);
scrollTimer = setTimeout(function() {
// Check your page position and then
// Load in more results
// Whatever else...
}, 250);
});