I think that assumption is completely unsupported. The purpose of a
document fragment is to provide a generic element to attach a bundle
of nodes to. It means you don't have to worry about adding TRs to a
table section, or TDs to a TR and so on, you just build the bit of
tree that you want and attach it to an appropriate location in the
DOM.
render = drawn. Either onscreen or in an offscreen buffer.
Jorge's example only shows that it is faster if you don't render the
table at all. It also shows browsers are clever enough not to bother
trying to render elements with display:none.
I don't think the actual creation time is affected at all. It's
reasonable to assume that the *total* time will be faster if the table
is never displayed. If you create the table with display:none, then
change to display:'' and add it to the document, it takes about the
same time as if you'd created it with display:'' from the start. That
indicates to me that it is only rendering the table once, at the end,
regardless of what the display property is set to during construction
of the table.
I don't follow. If display is none, then the table isn't rendered so
of course it's faster, the browser didn't have to render it at all.
How can the browser render a table that isn't part of the DOM yet? It
might be set to position absolute, or placed anywhere in the DOM, or
various other elements added, and so on. The browser would be simply
wasting time to attempt any kind of rendering until the table is
actually added to the DOM.
Of course, because with visibility:hidden, the browser must still make
room for the invisible table, even though it doesn't have to draw it.
If you want to test whether *building the table* takes more or less
time, measure the time it takes to build the table with display:''
*before* adding it to the document.
Yes, yes. I got it. I really do. My point is that, great, you've
pointed out a work-around to the problem. And my point that *unless*
you do specify display:none to the containing element, subsequent
inserts and appends *will* be rendered, whether they are attached to
the body or not.
No, it proves nothing of the sort. How does the browser know that the
"containing element" is until the table is added to the DOM?
They will not be shown as the DOM does not know
where to put them yet but they will be rendered in the context of the
table.
That makes no sense to me. If you set the table to display:none, it
isn't rendered at all. If you don't set it to display:none, the table
is built (probably in exactly the same time) and at the end, when you
attach it to the document, it is rendered. Clearly that will take
longer than if you don't render it at all.
Your example does not disprove this.
Stay away from double negatives, they are quite confusing. It clearly
shows that if the table has display:none, it isn't rendered at all.
It doesn't prove that it is rendered anew after each append.