[whatwg] Resource loading in browsing context-less Documents

Rafael Weinstein rafaelw at chromium.org
Fri Oct 5 10:44:40 PDT 2012


On Fri, Oct 5, 2012 at 1:23 AM, Anne van Kesteren <annevk at annevk.nl> wrote:
> On Fri, Oct 5, 2012 at 8:00 AM, Ian Hickson <ian at hixie.ch> wrote:
>> This is specced. The UA is allowed to send the HTTP request (that's a
>> truism, of course, nothing stops the UA from sending any arbitrary HTTP
>> request at any time), but there's no in-DOM visible effect of that
>> request, because event loops don't process tasks for documents without
>> active browsing contexts, so the tasks that the "fetch" algorithm
>> generates never get executed. (A clever UA can notice this and delay
>> (forever) the HTTP requests, since the "fetch" algorithm allows you to
>> wait an arbitrary amount of time before doing the request.)
>
> Note that you can append such an <img> to a different document later
> (e.g. the one that executes the script) so fetching it is probably
> smart.

I'm not sure I get this. Generally, what you describe (pre-fetching)
is the behavior you'll get if you do the standard thing of

var img = document.createElement('img');
img.src = '/some/url.jpg';

Why is it useful to go to trouble of doing
document.implementation.createHTMLDocument('foo').createElement('img')
and have that fetch? The opposite seems true to me. It seems useful
that there's a way to create elements which explicitly are inactive.
It creates a safe playground to assemble DOM without worrying about
intermediate states triggering externally visible effects.

>
>
> --
> http://annevankesteren.nl/



More information about the whatwg mailing list