Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code>main() { print('Hello, Dart!'); } </code></pre> <p>When compiled with dart2js <strong>(as of 2013-04-26)</strong> (see note at bottom) it is converted into:</p> <pre><code>// Generated by dart2js, the Dart to JavaScript compiler. // The code supports the following hooks: // dartPrint(message) - if this function is defined it is called // instead of the Dart [print] method. // dartMainRunner(main) - if this function is defined, the Dart [main] // method will not be invoked directly. // Instead, a closure that will invoke [main] is // passed to [dartMainRunner]. function Isolate() {} init(); var $ = Isolate.$isolateProperties; // Bound closures $.Primitives_printString = function(string) { if (typeof dartPrint == "function") { dartPrint(string); return; } if (typeof window == "object") { if (typeof console == "object") console.log(string); return; } if (typeof print == "function") { print(string); return; } throw "Unable to print message: " + String(string); }; $.main = function() { $.Primitives_printString("Hello, Dart!"); }; $.String = {builtin$cls: "String"}; var $ = null; Isolate = Isolate.$finishIsolateConstructor(Isolate); var $ = new Isolate(); // BEGIN invoke [main]. if (typeof document !== "undefined" &amp;&amp; document.readyState !== "complete") { document.addEventListener("readystatechange", function () { if (document.readyState == "complete") { if (typeof dartMainRunner === "function") { dartMainRunner(function() { $.main(); }); } else { $.main(); } } }, false); } else { if (typeof dartMainRunner === "function") { dartMainRunner(function() { $.main(); }); } else { $.main(); } } // END invoke [main]. function init() { Isolate.$isolateProperties = {}; Isolate.$finishIsolateConstructor = function(oldIsolate) { var isolateProperties = oldIsolate.$isolateProperties; isolateProperties.$currentScript = typeof document == "object" ? document.currentScript || document.scripts[document.scripts.length - 1] : null; var isolatePrototype = oldIsolate.prototype; var str = "{\n"; str += "var properties = Isolate.$isolateProperties;\n"; var hasOwnProperty = Object.prototype.hasOwnProperty; for (var staticName in isolateProperties) { if (hasOwnProperty.call(isolateProperties, staticName)) { str += "this." + staticName + "= properties." + staticName + ";\n"; } } str += "}\n"; var newIsolate = new Function(str); newIsolate.prototype = isolatePrototype; isolatePrototype.constructor = newIsolate; newIsolate.$isolateProperties = isolateProperties; return newIsolate; }; } //@ sourceMappingURL=out.js.map </code></pre> <p><strong>Note for posterity:</strong> The original answer to this question has been modified to reflect the current state of affairs.</p> <p>On 2012-05-12 the dart output for Hello World was 18,718 characters.</p> <p>On 2012-08-29 the output was 1531 characters.</p> <p>On 2013-04-26, the output was 2642 characters.</p> <p>dart2js can minify code. Here is an example (as of 2013-04-26)</p> <pre><code>// Generated by dart2js, the Dart to JavaScript compiler. function I(){} init() var $=I.p $.ib=function(a){if(typeof dartPrint=="function"){dartPrint(a) return}if(typeof window=="object"){if(typeof console=="object")console.log(a) return}if(typeof print=="function"){print(a) return}throw "Unable to print message: " + String(a)} $.E2=function(){$.ib("Hello, Dart!")} $.qU={builtin$cls:"qU"} var $=null I = I.$finishIsolateConstructor(I) var $=new I() if (typeof document !== "undefined" &amp;&amp; document.readyState !== "complete") { document.addEventListener("readystatechange", function () { if (document.readyState == "complete") { if (typeof dartMainRunner === "function") { dartMainRunner(function() { $.E2(); }); } else { $.E2(); } } }, false); } else { if (typeof dartMainRunner === "function") { dartMainRunner(function() { $.E2(); }); } else { $.E2(); } } function init(){I.p={} I.$finishIsolateConstructor=function(a){var z=a.p z.$currentScript=typeof document=="object"?document.currentScript||document.scripts[document.scripts.length-1]:null var y=a.prototype var x="{\n" x+="var properties = I.p;\n" var w=Object.prototype.hasOwnProperty for(var v in z){if(w.call(z,v)){x+="this."+v+"= properties."+v+";\n"}}x+="}\n" var u=new Function(x) u.prototype=y y.constructor=u u.p=z return u}}//@ sourceMappingURL=out.js.map </code></pre> <p>On 2013-04-26, the minified code was 1386 characters.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload