-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SSR and CSS #153
Comments
It depends. Yes, they would be forbidden by CSP. On the other hand, Google pushes for "critical CSS" which is inline |
Right now, the server-side renderer will bug out if it encounters a
<style>
tag. That's because CSS needs to be handled slightly differently – you can't include the<style>
tag with the generated HTML, because it would be duplicated for each instance of a component.So on the server, we need to gather all the (transformed, for scoped styles) CSS together for a component plus each of its nested components, in a form that lets us spit it out into a
.css
file (particularly useful in light of #152). On the client, we need to have a way to not inject<style>
tags (injecting them would be harmless but redundant if the server-rendered CSS is already on the page).Something like this:
One wrinkle: a page could have multiple top-level Svelte apps, which might share components. We need to provide a way for developers to dedupe CSS across those apps, while making the common case (collecting all the CSS together in a single blob) easy. We also need to make it possible to support CSS sourcemaps when we get round to that. So perhaps
thing.renderCss()
should return an object like this:Have I missed anything? Does that seem sensible?
css: false
renderCss()
svelte-[uniqueid]
attributes to elements at server-render timeThe text was updated successfully, but these errors were encountered: