DEV Community

Discussion on: All Javascript apps need event throttling!!!

Collapse
 
alaindet profile image
Alain D'Ettorre

Don't pay attention to people telling you optimization is not important, it is. Debouncing and throttling should be mandatory from the start when working with certain events like scrolling and HTTP calls.

A very nice tool is requestAnimationFrame
developer.mozilla.org/it/docs/Web/...

Essentially, it's a throttling function triggering a callback only upon browser re-paints, so that you can kind of delegate the optimization straight to the browser and forget about setTimeout, setInterval and such, at least for throttling.