Home » Javascript » Javascript print output one at a time instead of entire page at once?

Javascript print output one at a time instead of entire page at once?

Posted by: admin August 19, 2018 Leave a comment

Questions:

Just playing around a bit, but noticed it’s taking way too long for page to load, is there anyway to get it to print out one line at a time instead of having to wait till the entire page is loaded.

limits(){
    var a = 0;

    for (var i = 0; i < 1000; i++) {
        for (var ii = 0; ii < 1000; ii++) {
            document.getElementById('foo').innerHTML += "<p>" + a + "</p>";
            a * 2;

        }
    }
}

Now how would I be able to control this better to where regardless of how long it takes to load print as soon as ready and even slowing it down would be fine.

Answers: