[whatwg] Stat. on frequency of node insertion without children

Ryosuke Niwa rniwa at webkit.org
Fri Dec 2 23:24:47 PST 2011

Hi all,

Several days ago, we had a discussion about improving DOM performance on
#whatwg where I hypothesized that most of nodes inserted by methods like
insertBefore, appendChild, etc... don't have any children, and therefore we
can bypass checks for HIERARCHY_REQUEST_ERR by just checking the nullity of

To confirm my hypothesis, I made a custom build of WebKit and collected
statistics, and here's the result. The sample size is 3585 DOM API calls
while browsing facebook, twitter, gmail, google+, and webkit's bugzilla.

<number of nodes inserted per DOM API call> <percentage>
   1 52.887%
   2 9.763%
   3 6.416%
100+ 5.132%
   7 4.686%
   6 2.566%
   5 2.120%
   4 1.339%
   8 1.032%
   9 0.837%

i.e. 52.9% of all inserted nodes don't have any children.

Ryosuke Niwa
Software Engineer
Google Inc.

More information about the whatwg mailing list