読者です 読者をやめる 読者になる 読者になる

script 要素の defer と async 属性

HTML5

There are three possible modes that can be selected using these attributes. If the async attribute is present, then the script will be executed asynchronously, as soon as it is available. If the async attribute is not present but the defer attribute is present, then the script is executed when the page has finished parsing. If neither attribute is present, then the script is fetched and executed immediately, before the user agent continues parsing the page. The exact processing details for these attributes is described below.

The defer attribute may be specified even if the async attribute is specified, to cause legacy Web browsers that only support defer (and not async) to fall back to the defer behavior instead of the synchronous blocking behavior that is the default.

Changing the src, type, charset, async, and defer attributes dynamically has no direct effect; these attribute are only used at specific times described below (namely, when the element is inserted into the document).

async サポートしてるブラウザがわからない。と思ったら Opera9 だけらしい。まじすか。Google のやつあんまあてにならん。defer は FF3.5。Webkit は対応無し。

defer って一応仕様なんだけどなぁ。