Re: Node append

On 9/20/11 6:39 PM, Ojan Vafai wrote:
> The added benefit of these APIs is worth some performance hit.

How much?

It feels like having fast primitives that you can then compose is also 
worthwhile, and you're throwing that baby out with the syntactic sugar 

> e.g. appending an array should be faster than appending each
> node inside the array with individual appendChild calls, right?

Maybe.  Maybe not.  Especially when you consider the cost of 
constructing the array to start with as opposed to appending the nodes 
as you create them or whatnot....

The case for a string version of this is stronger; we have existing 
things like innerHTML and so forth that are in fact faster than building 
a DOM node by node in browsers.

But consider a self-hosted DOM implementation, in which the multiple 
appendChild calls can in fact be pretty darned cheap, even comparing to 
a single appendChild(array) call with the implementation then having to 
figure out it's an array, etc.


Received on Wednesday, 21 September 2011 02:42:02 UTC