Re: [whatwg] Questions about script attributes in HTML5
On Thu, 29 Jul 2010, zhao Matt wrote: Quote: The async and defer attributes are boolean attributes that indicate how the script should be executedThe defer attribute may be specified even if the async attribute is specified Do it mean 'async' is equivalent to 'defer'? (namely, are the two attributes interchangeable?) No. Quote: The defer and async attributes must not be specified if the src attribute is not present. Do it mean if the src attribute is not present, the defer and async attributes can be not used ? (English is not my native language, :) ) Yes. However, I saw the defer attribute can work on both in-line and external scripts . In short, when the src attribute is not present, the defer attributes can be used. We disallow that because there are some serious compatibility issues regarding document.write() and innerHTML if you implement defer= on inline scripts, so it was easier to just make it not work. -- Ian Hickson U+1047E)\._.,--,'``.fL http://ln.hixie.ch/ U+263A/, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Re: [whatwg] Questions about script attributes in HTML5
Aryeh Gregor wrote: Quote: The defer and async attributes must not be specified if the src attribute is not present. Do it mean if the src attribute is not present, the defer and async attributes can be not used ? (English is not my native language, :) ) Yes. I don't know why defer isn't allowed here -- maybe someone else knows the answer. Defer isn't allowed here, because it gets ignored. It gets ignored, because existing content calls document.write from internal scripts that specify defer. Deferring such scripts would lead to badness, obviously. Also, specifying defer or async on internal scripts makes no sense, since the whole point is managing the concurrency of network fetches, and you don't new separate fetches for internal scripts. -- Henri Sivonen hsivo...@iki.fi http://hsivonen.iki.fi/
[whatwg] Questions about script attributes in HTML5
Quote: The async and defer attributes are boolean attributes that indicate how the script should be executedThe defer attribute may be specified even if the async attribute is specified Do it mean 'async' is equivalent to 'defer'? (namely, are the two attributes interchangeable?) I personally consider the two attributes are different. The reason is as follows, ASYNC tells the browsers to run the script with its following content at the SAME time(namely, asynchronously). DEFER tells the browsers to run the script LATER, and to run the following content first(the browsers will run the script until the page is ready). Quote: The defer and async attributes must not be specified if the src attribute is not present. Do it mean if the src attribute is not present, the defer and async attributes can be not used ? (English is not my native language, :) ) However, I saw the defer attribute can work on both in-line and external scripts . In short, when the src attribute is not present, the defer attributes can be used. Could you give some expanations or tips? thanks e.g. script type='text/javascript' alert(1); /script script type='text/javascript' defer='defer' alert(defer); /script script type='text/javascript' alert(2); /script -Matt
Re: [whatwg] Questions about script attributes in HTML5
On Wed, Jul 28, 2010 at 1:20 PM, zhao Matt mattzhao...@gmail.com wrote: Quote: The async and defer attributes are boolean attributes that indicate how the script should be executedThe defer attribute may be specified even if the async attribute is specified Do it mean 'async' is equivalent to 'defer'? (namely, are the two attributes interchangeable?) No. It just means that you can specify both, like script async defer src=myscript.js/script. In this case, async takes precedence and defer is ignored in conforming browsers. Quote: The defer and async attributes must not be specified if the src attribute is not present. Do it mean if the src attribute is not present, the defer and async attributes can be not used ? (English is not my native language, :) ) Yes. I don't know why defer isn't allowed here -- maybe someone else knows the answer.