Skip to content

Instantly share code, notes, and snippets.

@SergeyNarozhny
Created July 21, 2015 13:09
Show Gist options
  • Save SergeyNarozhny/2f51d22a262444cf2775 to your computer and use it in GitHub Desktop.
Save SergeyNarozhny/2f51d22a262444cf2775 to your computer and use it in GitHub Desktop.
Throttle native js realization
function throttle(method, context)
{
clearTimeout(method.tId);
method.tId = setTimeout(function(){
method.call(context);
}, 100);
}
//usage example
window.onresize = function()
{
throttle(resizeDiv); //throttle function resizeDiv();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment