I\'ve got a doubt regarding performance in JS.
Say, I\'ve got the next code:
var divContainer = document.createElement(\"div\"); divContainer.id=\"co
I had the exact same question as the OP, and after reading through all the answers and the comments, it didn't seem like anybody really understood what the OP was asking.
I took a cue from the test Nicola Peluchetti posted and modified it a bit.
Instead of appending elements to a I took the original question to be, basically, is it faster to do a single append of nodes using a Looks like using a http://jsperf.com/document-fragment-test-peluchetti/39 The only use case I can think of for documentFragment, the fragment test gets the elements appended directly to it (the documentFragment) instead of first to the documentFragment, while each test only utilizes one or the other.
documentFragment as the container?
documentFragment (at the moment) is if it takes less memory (which could be negligible), or if you have a bunch of sibling nodes to append which you don't want to put into a "container" element. The documentFragment is like a wrapper which dissolves leaving only its contents.