[whatwg] Apply script.defer to internal scripts

 <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
present) 

 <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
present) 

 <http://www.whatwg.org/specs/web-apps/current-work/#type11> 

 

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
</script>

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.htm>

Received on Tuesday, 27 March 2007 12:49:41 UTC