- From: Ian Hickson <ian@hixie.ch>
- Date: Thu, 28 Apr 2011 22:04:49 +0000 (UTC)
- To: Kyle Simpson <getify@gmail.com>
- cc: public html <public-html@w3.org>
On Mon, 20 Dec 2010, Kyle Simpson wrote: > > > > IE has, for a long time, supported a "preloading" behavior on the > > <script> element itself. IE will begin downloading a resource once a > > dynamic script element's `src` attribute is set, but it will not > > execute that script (even once it finishes downloading) until after > > the script element has been directly appended to the DOM. In that way, > > a script can be "preloaded" by creating a script element but not > > appending it to the DOM, and then it can later be executed on-demand > > by appending it to the DOM. > > > > The `readyState` technique would probably be useful for this overall > > use-case (even for CSS if extended to the <link> tag as well), if it > > were standardized and available in all the browsers. > > HTML Spec, 4.3.1, 'Running a script' algorithm > http://www.w3.org/TR/html5/scripting-1.html#running-a-script > > Specifically, in step 12 (which is about fetching a `src` URL): > > "For performance reasons, user agents may start fetching the script as soon as > the attribute is set, instead, in the hope that the element will be inserted > into the document. Either way, once the element is inserted into the document, > the load must have started. If the UA performs such prefetching, but the > element is never inserted in the document, or the src attribute is dynamically > changed, then the user agent will not execute the script, and the fetching > process will have been effectively wasted." > > This seems to be the spec stating that browsers may do what IE's behavior on > scripts does, which is to start fetching the resource once the `src` property > is set, but not execute it until the script element is inserted into the DOM. > > It would seem then that browsers could/should be petitioned to consider > implementing this suggestion, perhaps taking the `readyState` implementation > from IE as guidance. > > The above wording, without guidance on how to detect the state (such as, with > `readyState`) is not overly useful to a developer for the "preloading" > use-case. But if an author can determine that the "preload" has finished by > examining a `readyState` property, then a resource loader can use that for the > use-case very effectively. > > Would the spec consider adding wording to this section to codify how IE's > `readyState` behaves in this circumstance? Could you clarify what use case you have in mind here? -- Ian Hickson U+1047E )\._.,--....,'``. fL http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,. Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
Received on Thursday, 28 April 2011 22:05:13 UTC