Performance: Internationalization (i18n)
MEDIUM IMPACT
Internationalization affects page load speed and rendering by adding extra data and logic for language support.
export async function loader({ params }) { const locale = params.lang || 'en'; const translations = await import(`./locales/${locale}.json`); return { translations: translations.default }; } // Loads only needed locale file dynamically
import allTranslations from './locales/all.json'; export function loader({ params }) { const locale = params.lang || 'en'; return { translations: allTranslations[locale] }; } // Component uses allTranslations object for every locale
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Load all translations at once | Minimal DOM changes | 0 reflows | Low paint cost | [X] Bad |
| Dynamic import of locale file | Minimal DOM changes | 0 reflows | Low paint cost | [OK] Good |