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

Improve SEO and initial load #2

Closed
arctic-hen7 opened this issue Sep 6, 2021 · 6 comments
Closed

Improve SEO and initial load #2

arctic-hen7 opened this issue Sep 6, 2021 · 6 comments
Assignees
Labels
C-enhancement Category: enhancement
Milestone

Comments

@arctic-hen7
Copy link
Member

This is a big change to the existing initial render model, and one that I've wanted to make for a while.

Presently, on first load, the user is sent a generic HTML file, no matter what page they asked for, which includes the app shell, which then fetches the appropriate content. However, this means two round trips to load the first page, and then the app shell smoothly takes over from there. This also means that any crawlers that don't execute Wasm won't get anything except a blank screen, which is atrocious SEO.

The solution I propose is instead performing the app shell process on the server for the first time a user requests a page, then rendering the page as normal on the server and injecting it into that generic HTML file. That way, the user will always be served a complete page on first render, and then the app shell takes over.

I should clarify that this problem only applies to the first render. All further navigations are handled internally by the app shell, which makes things much smoother, almost like an SPA (but much better on the server).

This approach is also friendlier to a future exporting system, because this process could be performed for every page in an export stage, and thus a fully static site could be created, eliminating the need for the server for projects that don't need more complex request-time strategies.

@arctic-hen7 arctic-hen7 added the C-enhancement Category: enhancement label Sep 6, 2021
@arctic-hen7 arctic-hen7 self-assigned this Sep 6, 2021
@lukechu10
Copy link
Contributor

There should also be a pure spa mode for those where SEO is not as important or who just like the simplicity of SPA. When creating an isomorphic app, sometimes we need to write client or server specific code which won't be necessary with a SPA.

@arctic-hen7
Copy link
Member Author

Could you give me an example of a situation in which that would be particularly useful?

@lukechu10
Copy link
Contributor

For example for sending HTTP requests, we only have to worry about client side, not server side. Of course, we could do this on the server-side and serialize it during the page load but that wouldn't work for something like, say, using firebase for realtime data.

@arctic-hen7
Copy link
Member Author

Couldn't that just be done in the existing system inside a component with a check for the definition of the window using web_sys?

@lukechu10
Copy link
Contributor

Sure, we could use conditional compilation but that makes everything more clumsy. SvelteKit has an option for this (even though it is generally not recommended) https://kit.svelte.dev/docs#ssr-and-javascript-ssr

@arctic-hen7
Copy link
Member Author

Hmm okay. Maybe open a separate issue for that then.

@arctic-hen7 arctic-hen7 added this to the v0.2.0 milestone Sep 12, 2021
This was referenced Sep 16, 2021
arctic-hen7 added a commit that referenced this issue Sep 17, 2021
Sensible modification/setting of the `<head>` is now possible. Still glitchy until #2 is sorted though.

Closes #13.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants