Skip to content

Instantly share code, notes, and snippets.

@hikarock
Created May 29, 2013 15:04
Show Gist options
  • Save hikarock/5670990 to your computer and use it in GitHub Desktop.
Save hikarock/5670990 to your computer and use it in GitHub Desktop.
_.debounce
* {
margin: 0;
padding: 0;
border: 0;
}
body {
background: #dff;
font: 30px sans-serif;
}
<button>save</button>
var delay = 10 * 1000;
var save = _.debounce(function() {
console.log("wait end");
// 超重い保存処理
}, delay);
function handler() {
console.log("wait start");
save();
}
$("button").on("click", handler);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment