Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hacked proof-of-concept for "Missing content" message flash fix. #45

Closed
wants to merge 8 commits into from

Conversation

dillonkearns
Copy link
Owner

@dillonkearns dillonkearns commented Jan 16, 2020

This is an experiment to explore one strategy for addressing #42.

You can view this page to see the current prototype of SSR in elm-pages: https://5e226204a2ae6a0008328c65--elm-pages.netlify.com/blog/introducing-elm-pages/

Note this doesn't technically do server-side rendering (SSR). Instead, it does the following:

  • Pre-render the view on the server
  • Once the pre-rendered view is rendered in the browser, the Elm app is initialized and then replaces the pre-rendered DOM

This can give similar benefits, but it's not exactly the same.

In terms of having a page that can be crawled by search engines without running JavaScript, and other similar SEO benefits, it's just as good. Some experimentation and measurements still need to be done to understand what kinds of issues there may be when the pre-rendered DOM is replaced by the client-rendered DOM.

Issues with this approach, known and unknown (testing, measurements, and observations are very welcome!)

Benefits that real SSR could provide

Current features

  • Doesn't call the user's update function during the pre-rendering stage. Instead, it just calls init so you will have control over what is presented in the pre-rendered view (and it is deterministic, rather than calling update a variable number of times depending on how long pre-rendering takes).

Possible experiments to try

  • Consider using requestAnimationFrame. Here's an Ellie illustrating a pre-rendered view being taken over with an Elm app that's initialized: https://ellie-app.com/m27khddMDya1. Also notice that the Ellie renders it off in a hidden view and the replaces the pre-rendered view when it's done.

@dillonkearns
Copy link
Owner Author

This was implemented with #48.

@dillonkearns dillonkearns deleted the ssr-prototype branch May 11, 2020 17:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant