Skip to content

Instantly share code, notes, and snippets.

@frosa-logrise
Created January 13, 2023 12:35
Show Gist options
  • Save frosa-logrise/2d7c9b123d0c871f83a0f703417a5a35 to your computer and use it in GitHub Desktop.
Save frosa-logrise/2d7c9b123d0c871f83a0f703417a5a35 to your computer and use it in GitHub Desktop.

Revisions

  1. frosa-logrise created this gist Jan 13, 2023.
    7 changes: 7 additions & 0 deletions Debounce Vanilla JS
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,7 @@
    function debounce(func, timeout = 300) {
    let timer;
    return ( ...args ) => {
    clearTimeout(timer);
    timer = setTimeout(() => { func.apply(this, args); }, timeout);
    }
    }