- From: timeless <timeless@gmail.com>
- Date: Wed, 9 Feb 2011 12:35:16 +0200
On Wed, Feb 9, 2011 at 12:08 PM, Alexandre Morgaut <Alexandre.Morgaut at 4d.com> wrote: > 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) i'm not sure you need an execute(), you might benefit from an event listener to tell you if a resource has been prefetched. but this general path seems less icky to me than most if not all of the other paths suggested in this thread.
Received on Wednesday, 9 February 2011 02:35:16 UTC