I've got a bit of javascript that dynamically adds elements to my page. The problem is that there are hundreds of elements to create on any given run, and although it takes less than a second to load a single element, the whole page may take 30 seconds or more to load completely, then everything suddenly springs up onto the page. My question is: how can I update the page so that my dynamically created element will be displayed as soon as it is created?
var newDiv = document.createElement('div');
for (var val in array) {
var newCanvas = document.createElement('div');
newCanvas.className = "graph";
newDiv.appendChild(newCanvas);
drawGraph(val, newCanvas); //adds a bunch of elements to newCanvas
addTitle(val, newCanvas); //adds another
addDescription(val, newCanvas); //adds another
}
document.body.appendChild(newDiv);