[whatwg] Apply script.defer to internal scripts

Kristof Zelechovski giecrilj at stegny.2a.pl
Tue Mar 27 12:49:41 PDT 2007

 <http://www.whatwg.org/specs/web-apps/current-work/#script> 3.17.1. The
script element specification says:

 <http://www.whatwg.org/specs/web-apps/current-work/#defer> defer (if the
<http://www.whatwg.org/specs/web-apps/current-work/#src10> src attribute is

 <http://www.whatwg.org/specs/web-apps/current-work/#async> async (if the
<http://www.whatwg.org/specs/web-apps/current-work/#src10> src attribute is



I understand that the async attribute must depend on the src attribute
because it is needed and meaningful only when the script element is loaded
from an external source; however, the advantage of using the defer attribute
is not limited to that case. 

Consider the following example:

<script type="text/javascript" defer>
function ha8validate(p5event) { return true }
document.forms[0].onsubmit = ha8validate

The script embedded here is so short and specific that it makes no sense
relaying it to an external location; however, if the script is not deferred,
the script fails with an exception at run time because the document body is
not constructed yet.  

Therefore, the defer attribute can be meaningful without the src attribute
and the dependency should be removed.


Yours sincerely

Christopher Yeleighton

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20070327/7c95347d/attachment-0001.htm>

More information about the whatwg mailing list