W3C home > Mailing lists > Public > whatwg@whatwg.org > February 2011

[whatwg] Proposal for separating script downloads and execution

From: Alexandre Morgaut <Alexandre.Morgaut@4d.com>
Date: Wed, 9 Feb 2011 11:08:20 +0100
Message-ID: <59730A9C-3443-4C8F-96E8-83AEB4F34AB0@4d.com>
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"


Note2
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)
Received on Wednesday, 9 February 2011 02:08:20 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:30 UTC