A jQuery/Zepto plugin I’ve been using a lot lately to debounce (= attach with delay) event handlers. To be applied on scroll events for example, as you don’t want one long single scroll to pull down the performance of your webpage by constantly triggering the attached handling function.

$(window).on('scroll', function(e) {
    // update stuff *after* the scroll
}, 250);

I prefer jquery.unevent.js over this jQuery#debounce() for example as jquery.unevent.js extends jquery#on() with a simple third timing parameter.

jquery.unevent.js (demo) →
jquery.unevent.js (source) →

Yes, I know: a repost. It’s just that good!

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.