W3C home > Mailing lists > Public > whatwg@whatwg.org > October 2012

Re: [whatwg] Resource loading in browsing context-less Documents

From: Rafael Weinstein <rafaelw@chromium.org>
Date: Fri, 5 Oct 2012 10:44:40 -0700
Message-ID: <CABMdHiSnFcbtOTDmVOK=D+8zUitoPX1aJZA43Jt238BTrWG=pQ@mail.gmail.com>
To: whatwg@whatwg.org
On Fri, Oct 5, 2012 at 1:23 AM, Anne van Kesteren <annevk@annevk.nl> wrote:
> On Fri, Oct 5, 2012 at 8:00 AM, Ian Hickson <ian@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/
Received on Friday, 5 October 2012 17:45:11 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 30 January 2013 18:48:11 GMT