dart-archive/www.dartlang.org

Change async modifier to defer in Dart scripts

Sfshaza opened this issue · 2 comments

An async script executes before the whole page is available (in chrome), but defer waits until the page has loaded. In cases where you want to make sure that all the DOM on the initial page is available from within your main function, you should use defer instead of async.

<script defer src="index.dart" type="application/dart"></script>
<script defer src="packages/browser/dart.js"></script>

I searched dartlang for instances of this, in all html and markdown files. There isn't much that needs fixing:

./articles/embedding-in-html/index.markdown:

1. Do not use async or defer attributes on your Dart script tag at this point.

./_includes/header.html:

<script async="" defer="" src="//survey.g.doubleclick.net/async_survey?site=apno2k33xucna4srya26u4i2ri"></script>

./docs/spec/examples/lazyloader/index.html:

<script async type="application/dart" src="main.dart"></script>

./docs/spec/examples/lazyloader/index.html:

<script async src="packages/browser/dart.js"></script>

This issue was moved to dart-lang/site-webdev#10