简体   繁体   中英

JavaScript - DOM Manipulation - Is construction a page first then attaching?

New to javascript...and dom manipulation...Let's say I'm using java-script to construct part of a page that has a bunch of sub-elements.

<div>my-sub-elements</div>

Should I create a stand-alone-div attach the elements inside then attach the whole thing to the DOM?

Or should I attach the elements one by one to the DOM?

通常,您不会注意到有什么区别,但是如果确实需要它,那么构造分离的DocumentFragment并将其附加到一个步骤中,要比将实时DOM树多次弄乱要快得多。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM