This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 22539 - [Shadow]: Add support for external stylesheets using link rel="stylesheet"
Summary: [Shadow]: Add support for external stylesheets using link rel="stylesheet"
Status: RESOLVED MOVED
Alias: None
Product: WebAppsWG
Classification: Unclassified
Component: HISTORICAL - Component Model (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: ---
Assignee: Hayato Ito
QA Contact: public-webapps-bugzilla
URL:
Whiteboard:
Keywords:
: 19276 (view as bug list)
Depends on:
Blocks: 15480
  Show dependency treegraph
 
Reported: 2013-07-02 16:19 UTC by Steve Orvell
Modified: 2015-05-27 02:45 UTC (History)
4 users (show)

See Also:


Attachments

Description Steve Orvell 2013-07-02 16:19:39 UTC
It is, of course, possible to use external stylesheets within a <style> element via @import. The spec should consider adding support also for including stylesheets via link rel="stylesheet" because:

1. it's simpler
2. it's familiar
3. to avoid possible negative characteristics of @import: https://developers.google.com/speed/docs/best-practices/rtt#AvoidCssImport
Comment 1 Steve Orvell 2013-07-02 16:23:46 UTC
We should be able to dimiss point #3 since we're comparing link rel="stylesheet" to:

  <style>
    @import url(sheet.css);
  </style>
Comment 2 Dimitri Glazkov 2013-07-17 16:48:48 UTC
*** Bug 19276 has been marked as a duplicate of this bug. ***
Comment 3 Hayato Ito 2014-05-29 08:46:11 UTC
Hi Steve, is this feature request still valid?

I think this feature request makes sense. Looks reasonable to me.
Comment 4 Dimitri Glazkov 2014-05-29 16:02:15 UTC
Just as an idea: can we look at how this would desugar into an imperative API?

Elliott had this notion of:

var stylesheet = new CSSStyleSheet(url);
root.stylesheets.add(stylesheet).

Is this basically it?
Comment 5 Steve Orvell 2014-05-29 16:37:41 UTC
I agree with Dimitri and he has a good basic summary.

We need to resolve the fetching issues with using remote stylesheets in shadowRoots before adding any new behavior, and the imperative api Dimitri outlined should address this.

The basic problem is that if a style element that has remote content (@import) is added to a shadowRoot, the remote content is fetched. Imagine that an author wants to create N shadowRoots. The author uses the best practice of putting style elements inside shadowRoot but wants to use a remote stylesheet in each one. This currently requires N network requests, even if there is only 1 referenced remote stylesheet.

The idea behind `root.stylesheets.add(stylesheet)` is that you can apply a stylesheet to a shadowRoot without causing it to re-fetch or parse.
Comment 6 Hayato Ito 2014-05-30 05:02:10 UTC
Thank you. That looks very reasonable argument and looks very important from the view of the performance. Totally agreed.

(In reply to Steve Orvell from comment #5)
> I agree with Dimitri and he has a good basic summary.
> 
> We need to resolve the fetching issues with using remote stylesheets in
> shadowRoots before adding any new behavior, and the imperative api Dimitri
> outlined should address this.
> 
> The basic problem is that if a style element that has remote content
> (@import) is added to a shadowRoot, the remote content is fetched. Imagine
> that an author wants to create N shadowRoots. The author uses the best
> practice of putting style elements inside shadowRoot but wants to use a
> remote stylesheet in each one. This currently requires N network requests,
> even if there is only 1 referenced remote stylesheet.
> 
> The idea behind `root.stylesheets.add(stylesheet)` is that you can apply a
> stylesheet to a shadowRoot without causing it to re-fetch or parse.
Comment 7 Hayato Ito 2015-05-27 02:45:47 UTC
Moved to https://github.com/w3c/webcomponents/issues/82