Last active
October 10, 2016 02:26
-
-
Save ktrysmt/6dffea53a73e7e159033f01ac5e34918 to your computer and use it in GitHub Desktop.
Using setImmediate with DOM operations.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var child = document.getElementById("id").childNodes | |
var length=child.length,start=0; | |
var MAX_EXECUTION_COUNT=100; | |
setImmediate(function loop(){ | |
for(var i=start;(i<start+MAX_EXECUTION_COUNT) && i<length ;i=(i+1)|0){ | |
console.log(child[i]) | |
} | |
if(i<length){ | |
start += MAX_EXECUTION_COUNT; | |
setImmediate(loop,0); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment