[whatwg] Proposal for separating script downloads and execution

I had chatted with a few folks about using rel=prefetch, but there seems to be a lot of issues that would have to be resolved to get the behavior I'm after. Prefetching in this way is very passive, currently implemented as happening during user idle time, which is unpredictable (not to mention the issues Glen mentioned below). 

I think Glen summed this up correct by saying that prefetching is a hint, and when you want to load a script you want it to happen. This isn't to say that you wouldn't want to prefetch a script, but I see that as more of a way to help the next page you'll navigate to by priming the cache vs. helping the currently loaded page. 

In any event, it seems that rel=prefetch would have to change a lot vs. the changes to the script element to allow the same behavior.

-N

-----Original Message-----
From: whatwg-bounces@lists.whatwg.org [mailto:whatwg-bounces@lists.whatwg.org] On Behalf Of Glenn Maynard
Sent: Wednesday, February 09, 2011 6:15 AM
To: timeless
Cc: Alexandre Morgaut; whatwg at lists.whatwg.org
Subject: Re: [whatwg] Proposal for separating script downloads and execution

> 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:

Executing scripts out of a <link> seems very strange.

Prefetching can also be disabled by the user, heuristically disabled by the
browser or download at a lower priority.  There's no way to know in advance
whether that will happen--not just due to lack of an API to ask, but because
the browser can't always tell in advance.  Prefetching is a hint, where
script preloading shouldn't be; loaders must be able to know whether they
can load-without-executing or not.

--
Glenn Maynard

Received on Wednesday, 9 February 2011 07:40:06 UTC