question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RFC: Streaming SSR and it's impacts

See original GitHub issue

Edit: Update 6/Oct/2020

Because we’ve pivoted to atomic CSS things now are made more complicated. We still however need to maintain this story.


A note on design decisions - Right now Compileds primary goal is to introduce constraints that make it impossible to write unperformant CSS in JS. If we can solve the 90% here that is good enough.

Currently we operate essentially the same as Emotion’s default config.

SSR rendered markup:

<style>...</style>
<div class="abc">...</div>

Client markup:

<head>
  <style>...</style>
</head>
..
<div class="abc">...</div>

While this means SSR is 0 config and it just works (with streaming as a bonus) - it makes using any nth selectors annoying/shitty to use.

:first-child
:nth-child
:nth-of-type
:nth-last-of-type
:nth-last-child
:first-of-type
:last-child
* + *

I really want to solve this without re-architecting how things work for the default implementation. We need to investigate if we can do some CSS magic to create equivalent selectors for the 90% case that:

  1. works for ssr before js has executed (style before the component atm)
  2. works for client after js has executed (style in the head now)

Remember: The style element will move when JS executes. We need to handle both states.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:1
  • Comments:15 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
itsdougescommented, Oct 6, 2020

Cheers will do 🙂

cc @pgmanutd had some good discussion today ^

On Tue, 6 Oct 2020, 6:28 pm Jonathan Pollak, notifications@github.com wrote:

Feature queries (@supports blocks) also come to mind in the same way as media queries, but I’m sure there are other edge cases I’m just not thinking about right now.

I’m also not at all certain that the JS boilerplate required for the inline script based solution will be larger than duplication, especially non-trivially sized applications.

As an aside, regardless of how the server-side application of styles will happen, for the client-side style element insertion, I’d recommend Fela’s approach to style elements, as it enables a very clear separation of concerns (global, fonts, media query), and by so eases the task of sorting rulesets.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/atlassian-labs/compiled/issues/31#issuecomment-704086232, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABT4PHNB5ORJWFLXC6ZH7TTSJLBKLANCNFSM4KCVWUBQ .

1reaction
TxHawkscommented, Oct 6, 2020

Feature queries (@supports blocks) also come to mind in the same way as media queries, but I’m sure there are other edge cases I’m just not thinking about right now.

I’m also not at all certain that the JS boilerplate required for the inline script based solution will be larger than duplication, especially in non-trivially sized applications.

As an aside, regardless of how the server-side application of styles will happen, for the client-side style element insertion, I’d recommend Fela’s approach to style elements, as it enables a very clear separation of concerns (global, fonts, media query), and by so eases the task of sorting rulesets.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streaming server-side rendering (SSR) - Shopify Developers
This guide describes how streaming server-side rendering (SSR) works in a Hydrogen app. ... Streaming SSR provides the following performance benefits:.
Read more >
The future of rendering in React - Prateek Surana
Streaming allows the web server to send data to a client over a single HTTP connection that can remain open indefinitely. So you...
Read more >
LWC Server Engine - RFCs
Server-side Rendering (SSR) is a popular technique for rendering pages and components that would usually run in a browser, on the server.
Read more >
Why is SSR gaining so much popularity in 2022? : r/reactjs
Therefore one of the major downsides of run-time SSR e.g. inability to support CDN, has not been nullified yet. There are other downsides...
Read more >
React - Introducing Server and Shared Components
SSR is a technique to quickly render client-side applications on the server thereby returning a complete HTML markup, which was rendered in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found