code: function(func) {
  		var timeout, timestamp;
  		var wait = 99;
  		var run = function(){
  			timeout = null;
  			func();
  		};
  		var later = function() {
  			var last = Date.now() - timestamp;
  
  			if (last < wait) {
  				setTimeout(later, wait - last);
  			} else {
  				(requestIdleCallback || run)(run);
  			}
  		};
  
  		return function() {
  			timestamp = Date.now();
  
  			if (!timeout) {
  				timeout = setTimeout(later, wait);
  			}
  		};
  	}
docs: based on http://modernjavascript.blogspot.de/2013/08/building-better-debounce.html