Skip to main content

New site for Dart news and articles

For the latest Dart news, visit our new blog at  https://medium.com/dartlang .

Simplifying Dart's HTML bindings

Posted by Jacob Richman


We are changing the implementation of dart:html from a wrapper based solution to a wrapper-free solution.  The dart:html API will not change as part of this transition but it will no longer be possible to use dart:html and dart:dom from within the same isolate. Also, the dart:htmlimpl library will go away.

Why are we doing this?

  • Smaller compiler output because dead code elimination is more effective with the new solution.
  • Faster compile times as dart:html is expressed directly rather than being expressed as a wrapper layer on top of dart:dom.
  • Faster runtime execution and lower runtime memory usage as the overhead of wrapping and unwrapping is avoided.

This change will happen as soon as early next week.

A few tradeoffs include:

  • It will no longer be possible to import dart:html and dart:dom within the same isolate.  At some point we expect to remove dart:dom completely so it doesn’t make sense to try to support this use case.  Supporting it would be extremely difficult and fragile given wrapper free implementations of both libraries.
  • dart:htmlimpl is going away as it doesn’t make sense to expose publicly given that the implementation of dart:html on Dartium will continue to use wrappers for some time.  dart:htmlimpl was only needed before to work around known broken or missing functionality in dart:html.  This escape hatch will not be needed with the updated library as dart:html and dart:dom are generated by the same script so the dart:html versions of rapidly evolving APIs such as Web Audio API will always function just as well as the dart:dom versions.

Once the new version lands if there is functionality in dart:dom that you needed, but not in dart:html, please file bugs.