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:
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as React from "react"
|
||||
import Image from "next/image"
|
||||
import { motion } from "framer-motion";
|
||||
import { m } from "framer-motion";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
/* ── Base Card ── */
|
||||
@@ -15,7 +15,7 @@ interface CardProps {
|
||||
|
||||
export function Card({ children, hover = true, glass = false, className }: CardProps) {
|
||||
return (
|
||||
<motion.div
|
||||
<m.div
|
||||
whileHover={hover ? { y: -6 } : undefined}
|
||||
transition={{ duration: 0.35, ease: [0.16, 1, 0.3, 1] }}
|
||||
className={cn(
|
||||
@@ -27,7 +27,7 @@ export function Card({ children, hover = true, glass = false, className }: CardP
|
||||
)}
|
||||
>
|
||||
{children}
|
||||
</motion.div>
|
||||
</m.div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { motion, useInView } from "framer-motion";
|
||||
import { m, useInView } from "framer-motion";
|
||||
import { useRef } from "react";
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
@@ -26,7 +26,7 @@ export function TextReveal({
|
||||
return (
|
||||
<span ref={ref} className={cn("inline", className)}>
|
||||
{words.map((word, i) => (
|
||||
<motion.span
|
||||
<m.span
|
||||
key={i}
|
||||
className="inline-block mr-[0.28em] last:mr-0"
|
||||
initial={{ opacity: 0, y: 22, filter: "blur(4px)" }}
|
||||
@@ -42,7 +42,7 @@ export function TextReveal({
|
||||
}}
|
||||
>
|
||||
{word}
|
||||
</motion.span>
|
||||
</m.span>
|
||||
))}
|
||||
</span>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user