W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2011

Re: Node append

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Tue, 20 Sep 2011 22:41:32 -0400
Message-ID: <4E794EDC.3030508@mit.edu>
To: Ojan Vafai <ojan@chromium.org>
CC: Robin Berjon <robin@berjon.com>, www-dom@w3.org
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 
bathwater.

> 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.

-Boris
Received on Wednesday, 21 September 2011 02:42:02 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:14:08 GMT