- From: Ben Maurer <ben.maurer@gmail.com>
- Date: Wed, 23 Jul 2014 09:42:34 -0700
- To: Ian Hickson <ian@hixie.ch>
- Cc: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>, Boris Zbarsky <bzbarsky@mit.edu>, William Chan (ιζΊζ) <willchan@chromium.org>
Hey,
Yeah, I think that API would be perfect (assuming that whenneeded=true
initiates the fetch, but not the load into the document). In combination
with allowing the user to specify an attribute with a set of parameters to
the fetch algorithm (eg, a custom header) I think that would cover the use
cases I was thinking of.
-b
On Tue, Jul 22, 2014 at 5:33 PM, Ian Hickson <ian@hixie.ch> wrote:
> On Tue, 22 Jul 2014, Ben Maurer wrote:
> >
> > To follow this up with a concrete suggestion:
> >
> > var myfetch = window.fetch('my.css', {'fetch-as': 'stylesheet'});
> > myfetch.then(function(resp) {
> > document.body.appendChild(resp.body.asStyleSheet());
> > });
> > ...
>
> Why not:
>
> var mystyle = E('link', { rel: 'stylesheet', href: 'my.css',
> whenneeded: true });
> document.body.appendChild(mystyle);
> var myfetch = mystyle.fetch;
> ...
>
> ...where "E()" is some mechanism to easily create new elements (we need
> one of those regardless), and "whenneeded" is some attribute that controls
> the load policy (and in this case, tells it to not load yet, since I
> presume that's what you're going to do next with the "myfetch" variable)?
>
> ("whenneeded" here is a placeholder. I don't expect to actually go with
> that. I just used it because it's what I had proposed the last time this
> came up.)
>
> That seems like it'd be no more complicated, but would involve less new
> API surface (not to mention fewer new ways to shoot yourself in the foot,
> e.g. getting the 'fetch-as' value wrong), and wouldn't require us to come
> up with a way to enumerate all the kinds of fetch in an API.
>
> --
> Ian Hickson U+1047E )\._.,--....,'``. fL
> http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
> Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
>
Received on Wednesday, 23 July 2014 16:43:05 UTC