Convopage
See the entire conversation
Guillermo Rauch
@rauchg
Next.js 2.2.0 ◆ 1-line CDN support ◆ React `prop-types` ◆ Socket.IO, Firebase, Semantic UI, Material UI examples
zeit/next.js
next.js - Framework for server-rendered React apps
github.com
41 replies and sub-replies as of Apr 23 2017
Guillermo Rauch
@rauchg
+ all these changes! Thanks to the 14 contributors that have helped us since 2.1.1!
Guillermo Rauch
@rauchg
Particularly excited about built-in ETag support for server-rendered pages i.e.: clients won't download the same (dynamic!) content twice ⚡️
Andrew Del Prete
@AndrewDelPrete
That's really slick! Ya'll are doing some great work over there.
Guillermo Rauch
@rauchg
thank you!
Jon Kuperman
@jkup
These changes rock! Can't wait to check out this latest version!!
Malte Ubl
@cramforce
Do you buffer whole response to generate etag or do you have a different strategy (trailing header?)?
Guillermo Rauch
@rauchg
We don't support streaming yet, so we have to get the entire HTML tree from React first.
Malte Ubl
@cramforce
Ick. Better than no SSR, I guess. At least with fastish backends.
Guillermo Rauch
@rauchg
Not sure you get much with streaming if you're pre-rendering "above the fold" (or close) content, or fast backend.
Guillermo Rauch
@rauchg
If you expect your backend to be slow, it's best to pre-render the layout, and have the client display its data cache, lazily invalidate it
Malte Ubl
@cramforce
Flushing before body-open is almost always worth it. "above the fold" rendering with manual selection of the fast backends works, of course.
Guillermo Rauch
@rauchg
Yeah, getting the <head> out fast is important. We'll be able to do that fairly soon, with automatic rel=preload tags for page's scripts
Malte Ubl
@cramforce
I was advocating for trailing http status codes. Pains not to be able to flush a script tag before the database answers that resource exists
Sam Saccone
@samccone
Streaming wins come only if you are careful about what tags you are shipping ..a single non defer/async script will ruin it.
Malte Ubl
@cramforce
Streaming wins come often from early resource discovery where that doesn't matter.
Sam Saccone
@samccone
Depends :) Lotta complexity around network priority hueristics for resource discovery
Sam Saccone
@samccone
In my testing I have found the wins for streaming html resource discovery to be difficult to quantify on real pages
Guillermo Rauch
@rauchg
This is actually a big concern. Our early tests showed conflicting results w/ early discovery on slow download
Sam Saccone
@samccone
Yes this. Preload is stupid hard to get right and keep right
Malte Ubl
@cramforce
Flushing early for critical resources wins by definition. No measurement necessary.
Malte Ubl
@cramforce
For non-critical resources it depends, but putting bytes on the network instead of idling is a good default.
Sam Saccone
@samccone
Funny you bring up flushing. I discovered a hack technique of inserting an empty script tag in my document to force the browser to paint
Sam Saccone
@samccone
So if you have a large document and you know where you want to cause a layout paint operation to force a render. an empty script tag will do
Sam Saccone
@samccone
are we having fun yet?
Patrick Meenan
@patmeenan
May not be deterministic and may just be chrome (or different across browsers). Parser will yield before a script tag...
Sam Saccone
@samccone
*****hack****** 🤣😅😅😅😱
Patrick Meenan
@patmeenan
Oh yeah. Totally. I'd use hack to describe the chrome logic for it too (I added it)
Malte Ubl
@cramforce
Ah, I accidentally hit this for Google's SSR component renderer by emitting data via a script tag for each component.
Patrick Meenan
@patmeenan
If the script tags are near each other shouldn't be an issue. Spread through the document would yield a lot but also not always bad
Patrick Meenan
@patmeenan
Heuristics in general are hard and full of edge cases that fail hard. Would love to expose explicit dev control
Sam Saccone
@samccone
confirm('click to render')
Patrick Meenan
@patmeenan
Only if it has processed a bunch of other tokens but doesn't force a layout/paint. Just gives them a chance to happen.
Patrick Meenan
@patmeenan
Paint driven off vsync makes it racy. I'd like to make it deterministic but hard to do without slowing down parsing with a RAF delay
Richard Feldman
@rtfeldman
Any links to learn more about how to do streaming like this? First I've heard of it, but sounds interesting!
Sam Saccone
@samccone
In node it's trivial, just write to your response stream with some html :)
Richard Feldman
@rtfeldman
Oh I see - so streaming HTML to the client as it's rendered rather than waiting for rendering to finish before sending first byte.
Sam Saccone
@samccone
bingo :) There can be wins in there, but 99.98% of sites out there have MUCH lower hanging perf wins to do before this. 🤣
Artur Bergman (山男)
@crucially
Sadly no browsers support trailers despite me asking for it since 1979
Spencer Schoeben
@netspencer
WOW!
endless bummer
@sambreed
😂 lol I was 1 day too early for the CDN stuff! Y'all are on 🔥🔥🔥
Adrian le Bas
@adrianleb
GG WP 👌