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.
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. TheuseTranslation
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)
After (on this PR)