taverasmisael / taverasmisael.com

My personal website and blog. Build with an hybrid Astro SSR, SolidJS and TailwindCSS. Support for internazionalization and more.
https://taverasmisael.com
2 stars 0 forks source link

feat: remove i18n impact on the final bundle #33

Closed taverasmisael closed 7 months ago

taverasmisael commented 7 months ago

Closes #32

All pages currently use the i18n utility module, even if their text is static. All SolidJS components also use the utility for their texts. The problem is that most of the text can be known ahead of time and statically rendered, reducing the javascript loaded on every page.

This was possible with a big refactor on all pages and components and the useTranslation utility function. The useTranslation utility had to be revamped because it loaded ALL the translations available (only 2 for now), now and thanks to the dynamic imports we can progressively load only the necessary ones.

So far NO page loads the translations or the utilities client side, they're baked at build time. The contacts page is the only one that loads the utility but dynamically to show the errors, so if the form is submitted successfully, there is no need to load, even if it's a generic submit error. I could've also put this on build time, but it was fun to implement and opened the door to refactor the useTranslation and import the translations dynamically.

Before (on prod)

current

After (on this PR)

fix

vercel[bot] commented 7 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
taverasmisael-com ✅ Ready (Inspect) Visit Preview Mar 3, 2024 5:08pm