perf: optimize framer-motion bundle size and memoize dictionary fetching
- Wrap getDictionary with React cache to prevent redundant JSON parsing on the server - Create MotionProvider to globally initialize framer-motion LazyMotion with domAnimation - Replace standard 'motion' imports with 'm' across all animated client components (HomeClient, Navbar, GaleriClient, SSSClient, card, text-reveal) to drastically reduce First Load JS size
This commit is contained in:
+3
-2
@@ -1,4 +1,5 @@
|
||||
import 'server-only';
|
||||
import { cache } from 'react';
|
||||
|
||||
const dictionaries = {
|
||||
en: () => import('../dictionaries/en.json').then((module) => module.default),
|
||||
@@ -11,6 +12,6 @@ export const i18n = {
|
||||
locales: ['tr', 'en'],
|
||||
} as const;
|
||||
|
||||
export const getDictionary = async (locale: Locale) => {
|
||||
export const getDictionary = cache(async (locale: Locale) => {
|
||||
return dictionaries[locale]?.() ?? dictionaries.tr();
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user