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
+18 -18
View File
@@ -2,7 +2,7 @@
import { useState } from "react";
import Image from "next/image";
import { motion, type Variants } from "framer-motion";
import { m, type Variants } from "framer-motion";
import Link from "next/link";
import { Utensils, Umbrella, Home, Wind, Hotel, Star, MapPin, ArrowRight } from "lucide-react";
import { Button } from "@/app/components/ui/button";
@@ -128,30 +128,30 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<div className="relative z-10 text-center px-4 max-w-5xl mx-auto">
{/* Eyebrow */}
<motion.p
<m.p
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, delay: 0.1 }}
className="text-[10px] uppercase tracking-[0.3em] text-[var(--color-moy-gold)] mb-8 font-medium"
>
{dict.hero.eyebrow}
</motion.p>
</m.p>
{/* Main heading */}
<h1 className="text-5xl md:text-7xl lg:text-8xl font-serif text-white mb-8 leading-[0.95] tracking-tight">
<TextReveal text={dict.hero.title} delay={0.2} />
</h1>
<motion.p
<m.p
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ duration: 0.8, delay: 0.9 }}
className="text-base md:text-lg text-gray-300/90 mb-12 font-light max-w-xl mx-auto leading-relaxed"
>
{dict.hero.subtitle}
</motion.p>
</m.p>
<motion.div
<m.div
initial={{ opacity: 0, y: 16 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.7, delay: 1.1 }}
@@ -168,23 +168,23 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<ArrowRight size={14} className="group-hover:translate-x-1 transition-transform" />
</Link>
</Button>
</motion.div>
</m.div>
</div>
{/* Scroll indicator */}
<motion.div
<m.div
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
transition={{ delay: 1.6, duration: 0.6 }}
className="absolute bottom-8 left-1/2 -translate-x-1/2 flex flex-col items-center gap-2"
>
<span className="text-[9px] uppercase tracking-[0.25em] text-white/50">{dict.hero.scroll}</span>
<motion.div
<m.div
animate={{ y: [0, 8, 0] }}
transition={{ duration: 1.6, repeat: Infinity, ease: "easeInOut" }}
className="w-[1px] h-8 bg-gradient-to-b from-white/50 to-transparent"
/>
</motion.div>
</m.div>
</section>
{/* ── Marquee Strip ── */}
@@ -203,7 +203,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<div className="max-w-5xl mx-auto px-6">
<div className="grid grid-cols-2 md:grid-cols-4 gap-12 md:gap-6">
{STATS.map((s, i) => (
<motion.div
<m.div
key={s.label}
custom={i}
initial="hidden"
@@ -218,7 +218,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<p className="text-[10px] uppercase tracking-[0.2em] text-gray-500 mt-3">
{s.label}
</p>
</motion.div>
</m.div>
))}
</div>
</div>
@@ -236,7 +236,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5 gap-5">
{SERVICES.map((service, i) => (
<motion.div
<m.div
key={service.id}
custom={i}
initial="hidden"
@@ -263,7 +263,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
{service.desc}
</p>
</div>
</motion.div>
</m.div>
))}
</div>
</div>
@@ -281,7 +281,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<div className="space-y-20">
{VENUES.map((venue, i) => (
<motion.div
<m.div
key={venue.id}
initial={{ opacity: 0, y: 40 }}
whileInView={{ opacity: 1, y: 0 }}
@@ -321,7 +321,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<ArrowRight size={12} className="group-hover:translate-x-1 transition-transform" />
</Link>
</div>
</motion.div>
</m.div>
))}
</div>
</div>
@@ -341,7 +341,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
{TESTIMONIALS.map((t, i) => (
<motion.div
<m.div
key={i}
custom={i}
initial="hidden"
@@ -371,7 +371,7 @@ export default function HomeClient({ lang, dict }: { lang: string; dict: any })
<p className="text-[10px] uppercase tracking-[0.15em] text-gray-500 mt-0.5">{t.origin}</p>
</div>
</div>
</motion.div>
</m.div>
))}
</div>
</div>