[whatwg] Proposal for separating script downloads and execution

Alexandre Morgaut Alexandre.Morgaut at 4d.com
Wed Feb 9 02:08:20 PST 2011

Another approach:

The link tag is meant to support a "prefetch" value for the "rel" attribute asking to preemptively cache the resource:
 - http://blog.whatwg.org/the-road-to-html-5-link-relations#rel-prefetch
 - http://davidwalsh.name/html5-prefetch

We can then write:

<link rel="prefetch" type="text/javascript" src="myscript.js">

let the link HTML Element have an execute() method when the "type" attribute is one off a User-Agent supported Scripting Media Types:

      | text/javascript          | text/ecmascript          |
      | text/javascript1.0       | text/javascript1.1       |
      | text/javascript1.2       | text/javascript1.3       |
      | text/javascript1.4       | text/javascript1.5       |
      | text/jscript             | text/livescript          |
      | text/x-javascript        | text/x-ecmascript        |
      | application/x-javascript | application/x-ecmascript |
      | application/javascript   | application/ecmascript   |

(source: RFC 4329 "Scripting Media Types" - http://www.rfc-editor.org/rfc/rfc4329.txt )

let the execute property value be null otherwise

Note 1:
Glenn just told me: "I doubt it's possible to change an object's interface based on the current value of an attribute."
So, the execute() method may exits everytime and throw an Error like:
 "Wrong call, the resource is not executable"

The rel attribute can accept several values.
- http://www.whatwg.org/specs/web-apps/current-work/multipage/semantics.html#attr-link-rel

It may then accept an additional "script" value,
The link tag may take profit from a getElementsByRelationship(relationName) method similar to getElementsByClassName(className)
This way, prefetched scripts could be more easily retrievable (as any other link tag)

More information about the whatwg mailing list