3 ms·
In my experience SPA load rather fast. Only the first load and some crazy animations are really an issue. And the first load issue can be circumvented with pre
by k__ 11y ago
In my experience SPA load rather fast. Only the first load and some crazy animations are really an issue.
And the first load issue can be circumvented with pre-rendering the first page on the server.
I tried this with React and it worked like a charm. It even went so far, that the whole page doubled for SPA and complete-server-side app, when JS was deactivated.
- rajangdavis 11y agoThat sounds really cool! How simple/difficult was it to set up the prerendering and what kind of stack are you running?
- k__ 11y agoThe only ugly part was getting the client side React to pick up the server side markup when it comes "pre-filled" with dynamic data. The client needs to use the same data or else it will throw away the whole markup and re-render it. Fetch the data on the server before you render. Render the (static) markup with React and the data. Send the markup AND the (serialized) data to the client. The client will render the markup normally before React kicks in. The client React then needs a way to use the serialized data with the pre-rendered markup. Redux, for example, is a way to pass down this data to every component, so it's available at render. Normally, when writing React apps, you can simply load data async and show a place-holder while the request runs. If you want to render on server, all the data has to be fetched before, if it's loaded async, so the server can render synchronously.