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.


2 Responses to “Debounce Window resize callbacks in JavaScript”

  1. Anthony Tornambe August 10, 2016 at 9:44 am #

    Thanks for sharing a great post!

    • Rick August 10, 2016 at 9:46 pm #

      You’re welcome!

Leave a Reply

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