diff --git a/src/i18n/index.ts b/src/i18n/index.ts
index d75fc9d..c0d5418 100644
--- a/src/i18n/index.ts
+++ b/src/i18n/index.ts
@@ -3,9 +3,19 @@ import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
+// Only load German synchronously (default language)
import translationDE from './locales/de';
-import translationEN from './locales/en';
-import translationSR from './locales/sr';
+
+// Lazy load other languages when needed
+const loadLanguage = async (lng: string) => {
+ if (lng === 'en' && !i18n.hasResourceBundle('en', 'translation')) {
+ const { default: translationEN } = await import('./locales/en');
+ i18n.addResourceBundle('en', 'translation', translationEN, true, true);
+ } else if (lng === 'sr' && !i18n.hasResourceBundle('sr', 'translation')) {
+ const { default: translationSR } = await import('./locales/sr');
+ i18n.addResourceBundle('sr', 'translation', translationSR, true, true);
+ }
+};
i18n
.use(LanguageDetector)
@@ -14,19 +24,21 @@ i18n
resources: {
de: {
translation: translationDE
- },
- en: {
- translation: translationEN
- },
- sr: {
- translation: translationSR
}
},
- fallbackLng: 'en',
- supportedLngs: ['en', 'de', 'sr'],
+ fallbackLng: 'de',
+ supportedLngs: ['de', 'en', 'sr'],
interpolation: {
escapeValue: false
}
});
+// Load language bundle when language changes
+i18n.on('languageChanged', loadLanguage);
+
+// Load initial language if not German
+if (i18n.language && i18n.language !== 'de') {
+ loadLanguage(i18n.language);
+}
+
export default i18n;
\ No newline at end of file
diff --git a/vite.config.ts b/vite.config.ts
index 15dc5f8..60819e6 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -5,18 +5,24 @@ import mdx from '@mdx-js/rollup';
import remarkFrontmatter from 'remark-frontmatter';
import remarkMdxFrontmatter from 'remark-mdx-frontmatter';
-// Plugin to make CSS non-blocking using the print media trick
+// Plugin to make CSS non-blocking and remove unnecessary preloads
function asyncCssPlugin(): Plugin {
return {
name: 'async-css',
enforce: 'post',
transformIndexHtml(html) {
- // Convert blocking CSS to async loading with print media trick
- return html.replace(
+ // Convert blocking CSS to async loading
+ html = html.replace(
//g,
`
`
);
+
+ // Remove modulepreload for non-critical chunks (animations, icons loaded later)
+ html = html.replace(/\n?/g, '');
+ html = html.replace(/\n?/g, '');
+
+ return html;
}
};
}