W3C home > Mailing lists > Public > whatwg@whatwg.org > July 2014

Re: [whatwg] Fetch Objects and scripts/stylesheets

From: Anne van Kesteren <annevk@annevk.nl>
Date: Mon, 28 Jul 2014 09:54:48 +0200
Message-ID: <CADnb78jbrAHm7q4B6T=H9GJavRWrGZdEYQUawnyz5N1tK=Cf-g@mail.gmail.com>
To: Ben Maurer <ben.maurer@gmail.com>
Cc: "whatwg@lists.whatwg.org" <whatwg@lists.whatwg.org>, Boris Zbarsky <bzbarsky@mit.edu>, William Chan (ι™ˆζ™Ίζ˜Œ) <willchan@chromium.org>
On Wed, Jul 23, 2014 at 1:07 AM, Ben Maurer <ben.maurer@gmail.com> 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());
> });

If you have 'fetch-as' you need a strong guarantee that the response
can only be used for that purpose. How is that envisioned?

asStyleSheet() is an idea that was shot down before (back then it was
asHTML()) because it has the wrong layering semantics. We do not want
the Fetch layer to depend on the Layout layer.

> You can only call asStyleShet if fetch-as=stylesheet. Passing this
> parameter would cause the browser to do all the things it would do if it
> were fetching a stylesheet. For example, it would specify an accept header
> of text/css unless otherwise specified. It would request at the same
> priority as the browser requests other stylesheets (again, unless
> overridden with a yet-to-be-defined syntax). Rules around CORS and tainting
> would be identical to a normal stylesheet fetch (namely that you could
> call.asStyleSheet on a request to a different origin but it would have
> whatever restrictions the browser has on stylesheets from different
> origins). Links in the stylesheet would be interpreted relative to the URL
> used to load it, etc.

I have the feeling this should be a higher-level API as the browser
might also want to progressively parse the CSS and start speculatively
fetching the resources within.

Received on Monday, 28 July 2014 07:55:17 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 17:00:21 UTC