Throttle Function
Ensures a function is only called at most once every X milliseconds. Great for controlling scroll handlers and improving performance on frequent events.
JavaScript7/8/2025
#utilities#performance
JavaScript
function throttle(fn, limit = 300) { let lastCall = 0; return (...args) => { const now = Date.now(); if (now - lastCall >= limit) { lastCall = now; fn.apply(this, args); } }; }
...
Loading comments...