I believe that browsers redraw a document only when the script returns to an even loop, so it will not do anything until the end of your script.
In any case, some operations may cause the browser to perform some expensive operations, such as rearranging the sizes of elements in a document (for example, when retrieving the sizes of an element after performing some DOM operations). Thus, you should do DOM manipulations outside the document as much as possible.
If you have a lot of manipulations with some elements, it may be cheaper to remove it from the document tree, perform your manipulations and add it to the tree again.
arnaud576875
source share