Throttle

Throttles a function so it can't be called more often than a given delay.

Throttle

throttle(fn, delay)

Creates a new version of the function fn, which will not execute more often than once every delay milliseconds regardless of how many times it is called.

Arguments

fn

A function to be throttled.

delay

The number of milliseconds for which the function should be unable to be called after each time it is executed..

Examples

This button can only be activated every 200 ms:

This button can only be activated once every second: