I found an article in Events and timing in-depth, there is an example in this article:
function run() {
var div = document.getElementsByTagName('div')[0]
for(var i=0xA00000;i<0xFFFFFF;i++) {
div.style.backgroundColor = '#'+i.toString(16)
}
}
which says:
In most browsers, you see nothing until the script finishes, or until the browser pauses it with a message that ‘a script is running too long’.
which means I can't see animation while these code is executing.
But why?I don't quite understand this, is the code execute too fast? Or the render job is done after execute the code?
and why add a setTimeout
could show the animate?