← Todas las publicaciones
post10 de abril de 2026
Throttle — Limita la Tasa de Llamadas
#javascript#performance#throttle

javascript
function throttle(fn, limit) {
let inThrottle = false;
return function(...args) {
if (!inThrottle) {
fn.apply(this, args);
inThrottle = true;
setTimeout(() => (inThrottle = false), limit);
}
};
}
const onScroll = throttle(() => {
updateParallax();
}, 16); // ~60fps
window.addEventListener('scroll', onScroll);