[whatwg] Proposal for separating script downloads and execution

Alexandre Morgaut Alexandre.Morgaut at 4d.com
Wed Feb 9 03:03:50 PST 2011


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

you will surely take benefit from the onload event 

Actually this approach should already work in browsers supporting prefetch...

if the resource has already been fully loaded, the script calling for it will take profit from the cache
But what if it is only partially loaded ?
Is the User-Agent already smart enough to detect that there is already a request for this file and wait for it being fully loaded in the cache ?

Adding support of script mediatype or script relationship to the link tag:
- would make it possible for the browser to also pre-parse it.
- if execute() method is provided, it could take advantage of this pre-parsing while a eval on a string wouldn't

Another thing strongly missing in the support of the link tag is a content property to access to the content of the resource 
(which would be null if not loaded like for the XHR API)

This way, many resources loading could be more declarative instead of using XHR for anything




More information about the whatwg mailing list