Skip to content

docs: further clarify and reinforce the performance impacts of single page apps (SPAs) - #11637

Merged
Rich-Harris merged 39 commits into
mainfrom
fallback-docs
Aug 19, 2025
Merged

Rich-Harris merged 39 commits into
mainfrom
fallback-docs

Conversation

@benmccann

@benmccann benmccann commented Jan 14, 2024 •

Copy link
Copy Markdown
Member

A huge portion of SvelteKit apps in the wild that are failing core web vitals are single page apps. The percentage of SvelteKit apps which pass/fail are tracked on cwvtech.report leveraging data from HTTP Archive. Some folks at Google were able to supply me with a random sample of SvelteKit sites from this dataset. While investigating the failing sites, I saw that the most common cause of failure was extra round trips due to deployment as a SPA.

@changeset-bot

changeset-bot Bot commented Jan 14, 2024 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 8af8994

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@teemingc teemingc added the documentation Improvements or additions to documentation label Jan 15, 2024
@benmccann benmccann changed the title docs: clarify that fallback page is generated docs: clarify the harms of single page app (SPA) mode Jan 15, 2024
@benmccann benmccann changed the title docs: clarify the harms of single page app (SPA) mode docs: further clarify and reinfornce the harms of single page app (SPA) mode Jan 15, 2024
@benmccann benmccann changed the title docs: further clarify and reinfornce the harms of single page app (SPA) mode docs: further clarify and reinforce the harms of single page app (SPA) mode Jan 15, 2024
@benmccann benmccann changed the title docs: further clarify and reinforce the harms of single page app (SPA) mode docs: further clarify and reinforce the harms of single page apps (SPAs) Jan 15, 2024

@dummdidumm dummdidumm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gotta push back on the language of these changes and some of these changes in general - it sounds like we're on a crusade against SPA mode now. This creates FUD ("omg SPA mode always bad", which isn't true because it depends on your site) and may turn people off from using SvelteKit ("ok so they hate SPA I'll look for another framework that supports it better") which helps neither web vitals nor us.

I think there are other avenues to explore:

  • some kind of SvelteKit dev tools which somehow analyzes your page and gives you some tips what you can improve, where this plays a part
  • partial prerendering which will improve perceived performance and probably web vitals
  • understanding why people opt for SPA mode in the first place and solve the roadblocks towards leaving SSR enabled

## SSR

Server-side rendering (SSR) is the generation of the page contents on the server. SSR is generally preferred for SEO. While some search engines can index content that is dynamically generated on the client-side it may take longer even in these cases. It also tends to improve perceived performance and makes your app accessible to users if JavaScript fails or is disabled (which happens [more often than you probably think](https://kryogenix.org/code/browser/everyonehasjs.html)).
Server-side rendering (SSR) is the generation of the page contents on the server. Returning the page contents from the server via SSR (including with prerendering) is highly preferred for performance and SEO. It drastically improves performance by avoiding the introduction of an extra round trip necessary in a SPA and makes your app accessible to users if JavaScript fails or is disabled (which happens [more often than you probably think](https://kryogenix.org/code/browser/everyonehasjs.html)). While some search engines can index content that is dynamically generated on the client-side it is likely to take longer even in these cases.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really true - it's more about the perceived performance. The HTML is already there, but you still have the second roundtrip of fetching the JS which hydrates your stuff and then it's interactive. If your page doesn't work without JS it might feel just as bad.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'roundtrip' refers to the data that is inlined into the page (whether in the form of serialised server data or inlined event.fetch responses)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And if your site is content to be read, it's much more than perceived performance - it's actual performance

@svelte-docs-bot

Copy link
Copy Markdown

@Rich-Harris
Rich-Harris merged commit 359caf7 into main Aug 19, 2025
@Rich-Harris
Rich-Harris deleted the fallback-docs branch August 19, 2025 18:04
Copilot AI pushed a commit to Stadly/kit that referenced this pull request Mar 6, 2026
… page apps (SPAs) (sveltejs#11637)

* docs: clarify that fallback page is generated

* Update documentation/docs/25-build-and-deploy/50-adapter-static.md

Co-authored-by: Willow (GHOST) <[email protected]>

* Update documentation/docs/25-build-and-deploy/50-adapter-static.md

* try to do a better job scaring users away from spa mode

* tweak

* update glossary

* Update documentation/docs/40-best-practices/05-performance.md

Co-authored-by: Simon H <[email protected]>

* update aside

* update SEO wording

* update glossary to differentiate between SPAs used publicly vs internally

* address feedback

* Update documentation/docs/25-build-and-deploy/50-adapter-static.md

Co-authored-by: Simon H <[email protected]>

* clarify spa vs hybrid app

* clarifications. recommend a page name other than index.html to avoid conflicting with prerendering

* try to shrink/tighten up content

* Update documentation/docs/40-best-practices/05-performance.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/40-best-practices/05-performance.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/25-build-and-deploy/50-adapter-static.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/25-build-and-deploy/55-single-page-apps.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/25-build-and-deploy/55-single-page-apps.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/25-build-and-deploy/55-single-page-apps.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/40-best-practices/05-performance.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/60-appendix/60-glossary.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/60-appendix/60-glossary.md

Co-authored-by: Tee Ming <[email protected]>

* Update documentation/docs/60-appendix/60-glossary.md

Co-authored-by: Tee Ming <[email protected]>

* tweaks

* tweaks

* tweak

* fix

* gah whoops

* gah

* ffffuuuuu

* more

* fml

* godDAMNIT

---------

Co-authored-by: Willow (GHOST) <[email protected]>
Co-authored-by: Simon H <[email protected]>
Co-authored-by: Tee Ming <[email protected]>
Co-authored-by: Chew Tee Ming <[email protected]>
Co-authored-by: Rich Harris <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants