Skip to content
This repository has been archived by the owner on Dec 19, 2017. It is now read-only.

Polymer documentation should state reason and implication of placing <script> elements in <head> #706

Open
Sfshaza opened this issue Jul 21, 2016 · 12 comments

Comments

@Sfshaza
Copy link
Contributor

Sfshaza commented Jul 21, 2016

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

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

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]
Labels: Library-Polymer Docs-API Docs-Tutorials

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @nicolasgarnier on August 26, 2014 15:19

From [email protected] on January 09, 2014 02:46:03

Also related: issue 15229 .

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

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.

Cc: [email protected] [email protected] [email protected]

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

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 .

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @nicolasgarnier on August 26, 2014 15:19

From [email protected] on January 10, 2014 16:56:40

Cc: [email protected] [email protected]

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

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.

Cc: [email protected]

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @nicolasgarnier on August 26, 2014 15:20

From [email protected] on January 28, 2014 17:53:19

Owner: ---

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

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

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @nicolasgarnier on August 26, 2014 15:20

From [email protected] on May 30, 2014 17:10:49

Labels: -Library-Polymer

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @nicolasgarnier on August 26, 2014 15:20

From [email protected] on June 04, 2014 16:49:36

Labels: -Type-Defect Type-Documentation

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @nicolasgarnier on August 26, 2014 15:20

From [email protected] on July 01, 2014 13:41:22

Labels: -area-pkg Area-Site

@Sfshaza
Copy link
Contributor Author

Sfshaza commented Jul 21, 2016

From @kwalrath on July 21, 2016 22:13

Move to https://github.com/dart-lang/polymer-dart/issues.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

1 participant