popcode icon indicating copy to clipboard operation
popcode copied to clipboard

Serve full HTML contents on initial pageload

Open outoftime opened this issue 8 years ago • 4 comments

Right now Popcode renders completely client-side—the HTML response is basically just an empty document save for a stylesheet link and an empty div for React to render into. In principle, seems like there is no reason we shouldn’t be able to “server render” the initial state of the page into a static HTML file at compile time.

outoftime avatar Nov 18 '17 14:11 outoftime

Is this possible with Popcode hosted on S3? Don't we need a Node.js process to do server-side rendering with React?

ajgreenb avatar Nov 20 '17 19:11 ajgreenb

@ajgreenb or do we?

The proposal here is to pre-render a fully-cooked React-ready HTML page during deployment. Seems like it should in principle be possible!

outoftime avatar Nov 21 '17 02:11 outoftime

Ahhhhhhhhhhhhhhhhhhh

ajgreenb avatar Nov 21 '17 03:11 ajgreenb

Turns out there are several reasonably popular packages to do this:

All of the above seem to be implemented by loading the page in a headless browser, waiting for some amount of time, then taking a snapshot of the DOM. Not super satisfying but probably the only way to do it without explicit consideration at the level of application state management.

I do wonder if this would actually be a good experience, though—it seems like the outcome would likely be that the page loads and appears fully interactive but nothing actually works until the JS bundle loads. That is probably worse than just showing a loading animation for a few seconds, as we do now.

outoftime avatar May 04 '18 23:05 outoftime