From @nicolasgarnier on August 26, 2014 15:19
From [email protected] on January 09, 2014 03:01:17
URL (if available): Some of https://www.dartlang.org/polymer-dart/ https://www.dartlang.org/docs/tutorials/polymer-intro/ https://api.dartlang.org/docs/channels/stable/latest/polymer.html Issue/feedback: The first example on < https://www.dartlang.org/polymer-dart/ > places <script> elements in . The same holds for the sample code on < https://www.dartlang.org/docs/tutorials/polymer-intro/ > and the the sample code generated by Dart Editor when the user selects “Web application (using the polymer library)”.
I assume that there is a reason the sample codes using Polymer.dart tend to place <script> tags on top, such as to avoid the flash of unstyled content in some cases. However, this means that the Dart code and the compiled JavaScript code are executed at different timing. I was not the only one who was confused by this discrepancy (see issue 15125 ).
I think that the reason for putting <script> elements on top (assuming there is a reason) and implication of doing so (Dart and JavaScript behave differently) should be stated somewhere in the documentation of Polymer.dart.
(Needless to say, if there is no reason to put <script> elements on top, then the codes should be modified. Note that the page “Embedding Dart in HTML” < https://www.dartlang.org/articles/embedding-in-html/#dart-html-semantics > recommends to place <script> elements at the end of a document, seemingly to avoid this very discrepancy.)
Original issue: http://code.google.com/p/dart/issues/detail?id=15980
Copied from original issue: dart-archive/www.dartlang.org#811