-
Notifications
You must be signed in to change notification settings - Fork 33
Polymer documentation should state reason and implication of placing <script> elements in <head> #706
Comments
From @nicolasgarnier on August 26, 2014 15:19 From [email protected] on January 08, 2014 19:40:38 Siggi, could you take a first crack at defining what our policy and reasoning are? Owner: [email protected] |
From @nicolasgarnier on August 26, 2014 15:19 From [email protected] on January 09, 2014 02:46:03 Also related: issue 15229 . |
From @nicolasgarnier on August 26, 2014 15:19 From [email protected] on January 09, 2014 14:12:13 These are great points, @yu.asakusa thanks for filing this bug. I'm cc'ing a few others to confirm. Because of today's timing of Dart script tags in Dartium (Dartium launches code at dom-content-loaded), we should state our policy like we did in the 'embedding-in-html' article: put it at the end to keep the behavior consistent after compiling with dart2js. And, as you suggest, the examples should be modified to put the script tag at the end. We have design ideas to eventually support sync execution of Dart script tags, but it's not going to be available for a while. When we reach that point we'll probably revisit the policy. |
From @nicolasgarnier on August 26, 2014 15:19 From [email protected] on January 09, 2014 14:21:30 To best approximate Dartium behavior, the dart2js script should have a defer attribute. If you do this, then it can be anywhere in the file (head included). Related is https://code.google.com/p/dart/issues/detail?id=15229 . |
From @nicolasgarnier on August 26, 2014 15:19 From [email protected] on January 10, 2014 16:56:40 |
From @nicolasgarnier on August 26, 2014 15:20 From [email protected] on January 10, 2014 16:58:09 Pete, good point. Our skeleton app from Dart Editor should add defer. I've CC'ed Keerti. |
From @nicolasgarnier on August 26, 2014 15:20 From [email protected] on January 28, 2014 17:53:19 Owner: --- |
From @nicolasgarnier on August 26, 2014 15:20 From [email protected] on May 30, 2014 17:05:37 Labels: -Area-Documentation area-pkg Pkg-Polymer |
From @nicolasgarnier on August 26, 2014 15:20 From [email protected] on May 30, 2014 17:10:49 Labels: -Library-Polymer |
From @nicolasgarnier on August 26, 2014 15:20 From [email protected] on June 04, 2014 16:49:36 Labels: -Type-Defect Type-Documentation |
From @nicolasgarnier on August 26, 2014 15:20 From [email protected] on July 01, 2014 13:41:22 Labels: -area-pkg Area-Site |
From @kwalrath on July 21, 2016 22:13 Move to https://github.com/dart-lang/polymer-dart/issues. |
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
The text was updated successfully, but these errors were encountered: