4 ms·
What idiot downvoted this? This is the solution for companies using single page sites. You render the page server side using some headless browser and serve tha
by eloff 11y ago
What idiot downvoted this? This is the solution for companies using single page sites. You render the page server side using some headless browser and serve that on the first load (or always for search engine spiders, or people with JavaScript disabled.) That way you don't suffer the latency penalty on the first load and subsequent loads work as usual with a single page app. I'm pretty sure I read that twitter does this, but it might be some other big player.
- sanderjd 11y agoIt is definitely the solution, but I've yet to find the setup that makes it cheap and easy to do. Links welcome!
- firasd 11y agoReact will render HTML on the server side using the same code and data structures you use for dynamic components on the client side. https://facebook.github.io/react/ https://facebook.github.io/react/
- GordyMD 11y agoTo demonstrate this point for those not familiar. Here is an example of using React + Redux on the server to render with an initial state. https://github.com/GordyD/3ree/blob/master/server/universalApp.js https://github.com/GordyD/3ree/blob/master/server/universalA...
- Wintamute 11y agoReact + some sort sort of library to handle app state (Redux is recommended). You gain a modern componentised frontend app and the ability to render it server side. Server rendering of a React app is pretty simple, of order maybe a 100 lines of code or so. And that includes populating the server rendered pages from the same API as the frontend uses. Redux docs may be a decent place to start: http://rackt.github.io/redux/docs/recipes/ServerRendering.html http://rackt.github.io/redux/docs/recipes/ServerRendering.ht...
- mmahemoff 11y agoIt's a fine architecture, true. Maybe you're thinking of AirBNB, they popularised this "holy grail" model (http://www.oreilly.com/pub/e/3009 http://www.oreilly.com/pub/e/3009) since around 2012. Twitter did have to backtrack from the #newtwitter pure client-side model. Serving a 140-character string shouldn't require a 1+ MB payload. So maybe they server-generate their pages this way too now.