it takes a lot of time because it overpays. you must create a fragment of the document and then add the brothers.
When does DOM overflow occur?
Javascript Performance - Dom Reflow - Google Article
sleep will not solve your problem
on the other hand, you create a line containing innerhtml and add to innerhtml. the string material does not really require much performance, but when you run the .innerhtml command, it starts a process that parses your string and creates the elements and adds them. You cannot interrupt or add a delay.
The innerhtml process cannot be sleep or interrupted.
you need to generate the elements one after the other, and after adding 50 elements, create an establishment delay.
var frag = document.createDocumentFragment(); function addelements() { var e; for(i=0;i<50;++i) { e = document.createElement('div'); frag.appendChild(e); } dest.appendChild(frag); window.setTimeout(addelements,1000); }
Gergely Fehérvári
source share