Skip to content

Instantly share code, notes, and snippets.

@thiamteck
Created February 19, 2011 06:01
Show Gist options
  • Save thiamteck/834867 to your computer and use it in GitHub Desktop.
Save thiamteck/834867 to your computer and use it in GitHub Desktop.
JQuery, slicing long running script into batches to eliminate IE's "Stop running this script?" warning
$(document).ready(function(){
// original line that might trigger IE warning
// $(":button").button();
var $allButtons = $(":button");
var buttonCount = $allButtons.size();
var buttonized;
for(var i = 0; i < buttonCount; i = i + 100){
buttonized = applyButtons($allButtons, i, 100);
setTimeout(buttonized, 10);
}
});
function applyButtons(allButtons, i, batchSize){
return (function(){
allButtons.slice(i ,(i + batchSize)).button();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment