Lately there has been a change on how Dart can be started in the browser. Since no other browser except Dartium, a special build of Chromium, has built-in Dart support, the process has two possible strategies. This is evidenced if you start a simple project from Dart Editor and peek at the HTML file, especially the last script tag which points to dart.js in Dart project repository:
<script type="application/dart" src="hello.dart"></script>
<script src="http://dart.googlecode.com/svn/branches/bleeding_edge/dart/client/dart.js">
</script>
What does this dart.js
file do? The logic is basically as follows.
- If
navigator.webkitStartDart
is defined, then run that function. I believe this is specifically intended for Dartium only. - Otherwise, find all script tags which refer to
.dart
file and replace it with the corresponding.js
file. For example,hello.dart
will turn intohello.dart.js
.
This also means that if you just care about non-Dartium browsers, the payload could be simplified by including the generated JavaScript directly and skipping the bootstrapper completely. For the simple project referred before, the content could be just like:
<script src="hello.dart.js"></script>
Last but not least, this mailing-list post (dated Feb 5) states that this is still temporary, i.e. things may change again in the near future.