Re: [XBL] prefetch element underspecified?

Marcos Caceres wrote:
> 
> Hi,
> Just wondering, does anyone else think that the behavior of the 
> <prefetch> element is slightly underspecified? The spec provides limited 
> answers to the following questions:
> 
>   Do prefetched resources load synchronously or asynchronously? (it is 
> implied that it is asynchronous, but it doesn't say)

The spec doesn't require that loading happens at all. The element should 
be seen as a hint that the resource is likely to be used in the future.

>   While preloading, do these elements block the document's onLoad event 
> until they have loaded?

This is arguably an implementation detail. The author can't rely on the 
resource being there at all, so it shouldn't really matter if the event 
is fired before or after the resources are loaded.

>   Once the element actually starts loading, should it fire an event on 
> the implementation?
> 
>   Once an element has loaded, should it fire an event on the 
> implementation?
> 
>   If the element fails to load, should it fire an event on the 
> implementation?
 >
 >   If the src attribute points to an invalid url, does the UA fire an
 > event? or is it in error and ignored?

These are good questions and should IMHO be addressed by the spec. If we 
do fire load/error events we should require that some type of event is 
fired for UAs that ignore the <prefetch>

>   If the author finds the prefetch taking too long, how can they cancel 
> it? (Ie, should there be a scripting interface?)

Possibly removing the <prefetch> from the DOM would cancel it. If a 
resource is unimportant enough that you want to cancel it if it takes 
too long, is it really worth having a <prefetch> for?

>   What happens when the MIME type of the prefetched resource is unknown 
> to the User Agent?  for instance, the author prefetches 'foo.fum' of 
> type 'application/apples'

The UA doesn't do any processing on the fetched resource. It is simply 
fetched and put in cache.

>   Can I access the internals of the data I have preloaded from the 
> prefetch element? say, for instance, I load some RSS and I want to parse 
> it? (ie. why use prefetch instead of XHR or just javascript?)

If you want to access the data use XHR. <prefetch> is just a more 
convenient way to try to improve the user experience by reducing load times.

>   What's the scope of prefetch? can prefetched resources, like images 
> for example, be used  by a bound document? (implied no, but does not say)

You can use it for anything.

/ Jonas

Received on Wednesday, 25 April 2007 00:03:43 UTC