From the Blink Blog:

Finally we’d like to explore even larger ideas like moving the entire Document Object Model (DOM) into JavaScript.

What does this mean? Does it mean WebKit's DOM is currently not coded in JavaScript but in some other language? Does it mean that they want to expose more public accessors to the DOM? Or what?

1 Answer 1


The way I read it there are two options. But before we look into this, you have to understand how the old model works.

In most, if not all implementations of HTML rendering engines, the DOM is implemented in C or C++ and the JavaScript engine is an add-on that has bindings exported to the DOM. This makes sense, if you look at how HTML and JavaScript evolved. But a lot of time is wasted in marshaling the calls from JavaScript to C/C++ and back.

The first option is that the DOM becomes more closely bound to the JavaScript engine. Basically the DOM objects becomes core JavaScript objects, like Array. This does not do much except reduce some marshaling, since the DOM uses the native data types from the JavaScript engine. The DOM is then still implemented in C or C++.

The second option and probably what they mean, is that the actual DOM is implemented in JavaScript. The downside is that the access to the DOM is fully interpreted, but on the upside it removes any marshaling. This is probably a net gain, since the DOM is mostly data anyway.

Then again I can't give you a definite answer - I don't work for Google and thus don't have that much insight.

  • 1
    I don't think there is any overhead in binding special types compared to the "native" types of the JavaScript engines as that engine is written in C++ and all types are implemented using the same mechanism. What can be saved by using the native JavaScript types is a code as a lot of code needs to be duplicated for the native types and the DOM types.
    – Jan Hudec
    Commented Apr 10, 2013 at 7:29
  • From what I know (from es-discuss mailing list, for example), it is definitely the latter. There is a wish to have DOM written in JS, not just because of marshalling cost (which is there), but also for removing as much of the "exotic", "non-native", "special" objects from the language space as possible. DOM is big PITA for language designers, because it is special.
    – herby
    Commented Apr 10, 2013 at 8:23
  • There is a design document on this topic recently docs.google.com/document/d/…
    – subbul
    Commented Jan 21, 2014 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.