javascript - Fastest debounce implementation -


In my application, I have some heavy functions in the scrolling event. To limit the frequency of execution, Using the method:

  var timeout; Document.addEventListener ("scroll", function () {explicit timeout (timeout); timeout = set timeout (function () {// some heavy code}, 200);});  

Is there a better way to do this? Is not set up from time to time to be very heavy to fire?

EDIT: What concerns me with the most memory usage - I think every settimeout is allocating something, it is a memory allocation from the Chrome timeline (this bella :):

< P> Enter image details here


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -