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

Rewrite app with astro with preact #49

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

Conversation

yaodingyd
Copy link

@yaodingyd yaodingyd commented Jun 22, 2024

Fix #42.

This is my attempt to update app with a lighter, more performant way framework/library. It consists two major changes:

  1. use astro (https://astro.build/) for meta framework. Astro is designed to best work for static content heavy sites, and uses islands (https://docs.astro.build/en/concepts/islands/) architecture to selectively hydrate certain parts of the app, with user's choice to different loading strategy. It also supports different ui library component, so even if we don't use preact (I think we should), we can keep astro with a different UI component lib.
  2. use preact (https://preactjs.com/) to replace react. Preact is fast 3kB alternative to React with the API, so we keep all existing react components/hooks usage to reduce the cognitive load for a different UI lib, while getting better performance and smaller size.

preview site: https://flash-peach.vercel.app/

also take a look at the comparison: first image is current side, second is the astro/preact rewrite

loadtime: 400ms vs 100ms
componet js load: 49.8kb vs. ~10kb (5.2+3.1+1.5)

Screenshot 2024-06-21 at 10 18 40 PM Screenshot 2024-06-21 at 10 18 09 PM

@incognitojam
Copy link
Contributor

incognitojam commented Jul 5, 2024

I wonder if the perf gains come from switching to Preact, since most of the text content was already just in the index.html, is there anything for Astro to statically generate?

@yaodingyd
Copy link
Author

I already manually converted the previous app to index.astro so in this case, perf gains mostly come from Preact. Although this site is really simple enough that we have very distinct static and dynamic split. I think adding Astro here is to future-proof any feature additions that does not have this, that we can adopt to static generation

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