title: Scroll event firing too many times. I only want it to fire a maximum of, say, once per second
body: <p>I have a page with "infinite scroll". It calculates the difference between the end of the page and the current page and loads more content if this difference is small enough. The code is soemthing like this using jQuery:</p>
  
  <pre><code>$(window).on('scroll', function() {
      if (window.pageYOffset &gt; loadMoreButton.offsetTop - 1000)
          # load more content via ajax
  }
  </code></pre>
  
  <p>Now, the problem is that every time I scroll, this event fires multiple times per scroll. I would like fire at most every x milliseconds. How would I do this?</p>