Skip to content

Instantly share code, notes, and snippets.

@screeny05
Created September 14, 2017 09:14
Show Gist options
  • Save screeny05/aaa1e9b73d64affdcd272b0e8f4fd0ad to your computer and use it in GitHub Desktop.
Save screeny05/aaa1e9b73d64affdcd272b0e8f4fd0ad to your computer and use it in GitHub Desktop.
Idle Throttle - Just like a regular throttle, except that it waits for idle or timeout
var idleThrottle = function(cb, timeout){
var idleId;
return function(){
if(idleId){
cancelIdleCallback(idleId);
}
idleId = requestIdleCallback(cb, { timeout: timeout });
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment