debounce
Creates a debounced function that delays invoking the listener until after a specified delay.
debounce(listener, delay)
debounce(listener, delay)Parameters:
Usage:
window.addEventListener('resize', debounce(() => console.log('Triggered!'),3000));$('#myinput').on('change',debounce(function(){
//this code here will run after 5 seconds
console.log('changes saved!!')
},5000))('#myinput').click(debounce(function(){
//this code here will run after 5 seconds
console.log('changes saved!!')
},5000))('#myinput').on('input',(debounce(function(){
//this code here will run after 10 seconds
console.log('changes saved!!')
},10000))Last updated