Community Snippets

Debounce Function

by Abba Sali Aboubakar Mamate

JavaScript
#performance#utils#events
function debounce(fn, delay = 300) {
  let timeoutId;
  return (...args) => {
    clearTimeout(timeoutId);
    timeoutId = setTimeout(() => fn(...args), delay);
  };
}

Comments (0)

No comments yet.

Sign in to leave a comment.