Accessing the DOM attributes directly may be faster, although I assume that it will not be significantly faster:
var els = $('input'); for (var i = 0; i < els.length; i++) { els[i].checked = true; }
But, as you say, the biggest problem is probably rendering. You can try to set tolerance in setIntervals to 0 milliseconds. This will not speed anything up, but at least it will stop the βfreezeβ:
var els = $('input'), i = 0; var interval = setInterval(function () { var batchLen = i + 100 > els.length ? els.length : i + 100; for (; i < batchLen; i++) { els[i].checked = true; } if (i === els.length) clearInterval(interval); }, 0);
David tang
source share