Skip to content
This repository has been archived by the owner on Jul 30, 2019. It is now read-only.

Proposal: Calling stylesheets contextually #603

Closed
Yago opened this issue Sep 28, 2016 · 3 comments
Closed

Proposal: Calling stylesheets contextually #603

Yago opened this issue Sep 28, 2016 · 3 comments

Comments

@Yago
Copy link

Yago commented Sep 28, 2016

With the rise of HTTP/2, we are now able to stop concatenation our stylesheets and start to load them depending on the page needs. In his article, @jakearchibald describe some good practices to deal with multiple css files like calling them all in the <head> or better, next to the related component.

Having links in the <body> is something more HTTP/2 oriented, but not quite satisfying.

For example :

<body>
  <link rel="stylesheet" href="/comment.css">
  <section class="comments"></section>
</body>

I think that HTML has to evolve a bit to fit with this more modern approach of binding styles. What if we can directly bind stylesheet on the related component ? In fact, the style attribute can already do that. So, in the same way, what if we have a similar attribute styles who call a render-contextual stylesheet ? I can be something very elegant like :

<body>
  <section class="comments" styles="/comment.css"></section>
</body>

I don't find a similar issue (because it's too crazy), so feal free to close it quickly if it's irrelevant.

@Yago Yago changed the title Calling stylesheets contextually Proposal: Calling stylesheets contextually Sep 28, 2016
@adanilo
Copy link

adanilo commented Sep 30, 2016

Interesting. I guess the styles in such a case would act as before, i.e. global? What about async loading of the style resource, that could help faster load by not blocking, but with the associated risk of painting something before styles are loaded and then updating later. Perhaps you should propose this on the WICG list?

@jakearchibald
Copy link

@Yago can you talk a bit about why your solution is more satisfying than a link element? Does it behave any differently?

Maybe related: we used to have <style scoped> but it removed from the spec whatwg/html#552

@cynthia
Copy link
Member

cynthia commented Feb 22, 2017

We haven't heard back from the OP defending the proposal for the last 5 months, and this seems to overlap a bit (but not entirely) with <style scoped> which was dropped from the upstream spec.

The single difference I see (extrapolating a lot from the couple lines in the proposal) is that a stylesheet attached to an element would most likely start the selector scope from the element the stylesheet was attached to, which sounds neat for templates and components, but is a feature big enough that it should probably be incubated first.

I'm closing this as the OP hasn't defended over the course of a couple months - feel free to re-open or move to WICG in the event this should be pushed forward.

@cynthia cynthia closed this as completed Feb 22, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants