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:
mstfyldz
2026-06-04 12:50:23 +03:00
parent e1d8bae5a4
commit acf01c81fa
9 changed files with 59 additions and 44 deletions
+3 -3
View File
@@ -5,7 +5,7 @@ import Link from "next/link";
import Image from "next/image";
import { usePathname } from "next/navigation";
import { Menu, X, Globe } from "lucide-react";
import { motion, AnimatePresence } from "framer-motion";
import { m, AnimatePresence } from "framer-motion";
import { Locale } from "../dictionaries";
export default function Navbar({ lang, dict }: { lang: Locale; dict: any }) {
@@ -91,7 +91,7 @@ export default function Navbar({ lang, dict }: { lang: Locale; dict: any }) {
{/* Mobile Nav */}
<AnimatePresence>
{mobileMenuOpen && (
<motion.div
<m.div
initial={{ opacity: 0, y: -20 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -20 }}
@@ -114,7 +114,7 @@ export default function Navbar({ lang, dict }: { lang: Locale; dict: any }) {
<Link href={switchLanguage('en')} onClick={() => setMobileMenuOpen(false)} className={`text-sm ${lang === 'en' ? 'text-[var(--color-moy-gold)] font-bold' : ''}`}>English</Link>
</div>
</div>
</motion.div>
</m.div>
)}
</AnimatePresence>
</header>