Open LorisSigrist opened 2 months ago
This is an optimization that was pointed out to me by a dev from Galaxus.ch
We currently do a record-lookup for the language-specific message function when evaluating index-message functions
export const my_message = () => { return { en: en.my_message, de: de.my_message }[languageTag()]() }
If we instead had a canonical order for the languages we could do an array-lookup instead. This would save 3 chars per language per message.
export const my_message = () => [en.my_message, de.my_message][languageTagIdx()]()
If we have 5 languages on average, that's 15bytes per message, so on a page with 50 messages that would be over half a kb on a normal page. That's over 20%.
Context
This is an optimization that was pointed out to me by a dev from Galaxus.ch
We currently do a record-lookup for the language-specific message function when evaluating index-message functions
Proposal
If we instead had a canonical order for the languages we could do an array-lookup instead. This would save 3 chars per language per message.
If we have 5 languages on average, that's 15bytes per message, so on a page with 50 messages that would be over half a kb on a normal page. That's over 20%.