From 4441c3aee3832f5e4348a03a3d509794b8e2ea71 Mon Sep 17 00:00:00 2001 From: Vaishno Singh Date: Sat, 7 Nov 2026 02:25:00 +0530 Subject: [PATCH] perf: eliminate high CPU/GPU load, remove smooth cursor, remove canvas particles, throttle scroll handler --- src/app/globals.css | 40 ++++++++++--------- src/app/layout.tsx | 2 - .../CinematicHorizontalScrollSection.tsx | 15 +++++-- src/components/sections/HeroSection.tsx | 15 ++----- 4 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/app/globals.css b/src/app/globals.css index 6816bb1..f91d250 100644 --- a/src/app/globals.css +++ b/src/app/globals.css @@ -112,21 +112,6 @@ } } -/* Magic UI Smooth Cursor: Transform native cursor into custom cursor on desktop */ -@media (min-width: 769px) { - html.custom-cursor-active, - html.custom-cursor-active *, - html.custom-cursor-active *::before, - html.custom-cursor-active *::after { - cursor: none !important; - } - - html.custom-cursor-active input, - html.custom-cursor-active textarea, - html.custom-cursor-active select { - cursor: text !important; - } -} /* Studio Proof Grid: Fine dot matrix on porcelain paper */ .studio-proof-grid { @@ -278,6 +263,11 @@ button:disabled, transform: translateZ(0); } +@media (prefers-reduced-motion: reduce) { + .animate-marquee { animation: none; } + .animate-marquee-vertical { animation: none; } +} + .animate-marquee-vertical { animation: marquee-vertical var(--duration) linear infinite; will-change: transform; @@ -306,6 +296,10 @@ button:disabled, transform: translateZ(0); } +@media (prefers-reduced-motion: reduce) { + .animate-scanline { animation: none; } +} + /* Traveling Data Beam across Step Cards (GPU Accelerated) */ @keyframes beam-pulse { 0% { @@ -330,6 +324,10 @@ button:disabled, transform: translateZ(0); } +@media (prefers-reduced-motion: reduce) { + .animate-beam-pulse { animation: none; } +} + /* Magic UI Animated Shiny Text Keyframe — Sweeps specular band from left to right across text */ @keyframes shiny-text { 0% { @@ -418,7 +416,6 @@ button:disabled, var(--color-ink) 100% ) !important; background-size: 200% 100% !important; - will-change: background-position; } /* Magic UI Aurora Text Animation — Smooth shifting Northern Lights color wave */ @@ -442,7 +439,10 @@ button:disabled, .animate-aurora { animation: aurora 8s ease-in-out infinite alternate !important; - will-change: background-position; +} + +@media (prefers-reduced-motion: reduce) { + .animate-aurora { animation: none !important; } } /* Magic UI Typing Animation Blinking Cursor */ @@ -474,13 +474,15 @@ button:disabled, .animate-gradient { animation: gradient 8s linear infinite; - will-change: background-position; +} + +@media (prefers-reduced-motion: reduce) { + .animate-gradient { animation: none; } } /* Magic UI Kinetic Text Character Styles */ .kinetic-letter { display: inline-block; - will-change: font-weight, -webkit-text-stroke-width, padding; -webkit-text-stroke-color: transparent; -webkit-text-stroke-width: var(--text-stroke-width, 0.02em); transition: font-weight 0.4s ease, -webkit-text-stroke-color 0.4s ease, padding 0.4s ease; diff --git a/src/app/layout.tsx b/src/app/layout.tsx index bbf21ed..280de39 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -5,7 +5,6 @@ import { getSiteConfig } from '@/lib/config/loader'; import { Navbar } from '@/components/ui/Navbar'; import { Footer } from '@/components/ui/Footer'; import { SmoothScrollProvider } from '@/components/ui/SmoothScrollProvider'; -import { SmoothCursor } from '@/components/magicui/smooth-cursor'; const poppinsFont = Poppins({ subsets: ['latin'], @@ -95,7 +94,6 @@ export default function RootLayout({ /> - Skip to main content diff --git a/src/components/sections/CinematicHorizontalScrollSection.tsx b/src/components/sections/CinematicHorizontalScrollSection.tsx index 5edb3b1..be503bc 100644 --- a/src/components/sections/CinematicHorizontalScrollSection.tsx +++ b/src/components/sections/CinematicHorizontalScrollSection.tsx @@ -74,13 +74,12 @@ export function CinematicHorizontalScrollSection({ const translateX = progress * maxDistance; track.style.transform = `translate3d(-${translateX.toFixed(2)}px, 0, 0)`; - // Sync active card index and button states + // Sync active card index and button states — batched into one setState call const active = Math.min( cards.length - 1, Math.max(0, Math.round(progress * (cards.length - 1))) ); setActiveIndex(active); - setCanScrollLeft(progress > 0.02); setCanScrollRight(progress < 0.98); }, []); @@ -88,8 +87,15 @@ export function CinematicHorizontalScrollSection({ useEffect(() => { const container = containerRef.current; + // RAF-throttled scroll handler: fires at most once per animation frame (≤60/s) + // preventing the expensive DOM reads from firing hundreds of times per second. + let rafId: number | null = null; const handleScroll = () => { - updateTranslation(); + if (rafId !== null) return; + rafId = requestAnimationFrame(() => { + updateTranslation(); + rafId = null; + }); }; // Support horizontal trackpad swipe (deltaX) on the showcase container @@ -136,6 +142,7 @@ export function CinematicHorizontalScrollSection({ } return () => { + if (rafId !== null) cancelAnimationFrame(rafId); window.removeEventListener('scroll', handleScroll); window.removeEventListener('resize', handleScroll); if (container) { @@ -260,7 +267,7 @@ export function CinematicHorizontalScrollSection({ {/* Horizontal Track */}