Debounce Window resize callbacks in JavaScript

It's important to debounce the calls you do when listening to the resize window event. Otherwise your function could be called hundreds of times, slowing the user's performance.

The debounce function

We need the black magic first.

Your code here

As you can see we're passing a callback function and a timeout. You can experiment with different values to make it look more real time.

Enjoy.

2 comments

Leave a Reply

Add <code> Some Code </code> by using this tags.

*
*