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 page performance with server-side rendering #50

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

trentrand
Copy link

@trentrand trentrand commented Jul 14, 2024

Closes #42

These changes propose not replacing React to improve performance. With a combination of Server-Side Rendering and client code modifications, we can get the site to feel as performant as the Leaderboard.

Disable cache and give it a few refreshes.


Uses Vike to render the application at build-time. This reduces the amount of Javascript that must be fetched and executed before the page is displayed.

I also made some modifications to the client code to eliminate the visible INITIALIZING to READY state transition, allowing users to interact with the page immediately after load.

The manifest is now fetched silently in the background, typically taking only 10-30ms. If a user interacts before the fetch completes, the system waits for readiness before proceeding.

These changes eliminate all flashing that occurs on page load.


Metrics before change:
metrics-before

Metrics after change:
metrics-after

@trentrand trentrand force-pushed the trand/42-improve-page-performance branch from 3aa6def to 7b0551d Compare July 14, 2024 07:15
These changes use vite-plugin-ssr to render the page before sending it
to the client. This reduces the amount of Javascript that must be
fetched and executed before the page can be displayed.

This also adds a server.js file which is used to start the server
and handle requests.
This refactor eliminates the visible INITIALIZING to READY state
transition, allowing users to interact with the page immediately after
load.

The manifest is now fetched silently in the background, typically taking
only 10-30ms. If a user interacts before the fetch completes, the
system waits for readiness before proceeding.

These changes eliminate flashing that occurs on page load.
@trentrand trentrand force-pushed the trand/42-improve-page-performance branch from 7b0551d to 568c290 Compare July 14, 2024 07:19
@trentrand
Copy link
Author

trentrand commented Jul 14, 2024

Performance.mov

@trentrand trentrand marked this pull request as ready for review July 14, 2024 07:22
Replace server-side rendering with build-time rendering for the entire
application.

- Eliminates the need for a server to be running
- Renders all components at build time, including those that require
  client-side hydration
- Simplifies the development process by automatically handling
  components that require client-side hydration
@trentrand trentrand force-pushed the trand/42-improve-page-performance branch from e2bc052 to 33a19db Compare July 15, 2024 14:42
@trentrand
Copy link
Author

This might require some changes to .github/workflows/deploy.yml.

Let me know if you'd like me to address that.

@Technologeek
Copy link

Good work! Does this consider the fact that the app would be highly dynamic with expectations to support PWA in the near future? I get the first page load is best served through SSR but apart from that, what other benefit an SSR app provides in this context considering we don't need SEO.

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.

Replace React with something simple
2 participants