The example of this article analyzes the method of JavaScript document fragment operation. Share to everyone for your reference, specific as follows:
Using document fragmentation can improve page efficiency in some cases.
JavaScript Operations DOM is a performance-intensive process, in some cases, we have to do Dom loop operation, each of our operations on the DOM triggers "rearrangement", which seriously affects the energy consumption, generally the practice is to reduce the DOM operations as much as possible to reduce the "rearrangement."
With the process of looping the DOM, we chose to use document fragmentation (creatdocumentfragment) to add the content that needs to be added to the DOM once to the document fragment, and then add the document fragment to the DOM tree, which effectively reduces the number of operations dom.
I hope this article will help you with JavaScript programming.