Skip to content

perf: optimize bundle, assets and mobile sidebar#5

Merged
anhvuFE merged 1 commit into
mainfrom
perf/optimize-bundle-and-ui
May 9, 2026
Merged

perf: optimize bundle, assets and mobile sidebar#5
anhvuFE merged 1 commit into
mainfrom
perf/optimize-bundle-and-ui

Conversation

@anhvuFE
Copy link
Copy Markdown
Owner

@anhvuFE anhvuFE commented May 9, 2026

Summary

  • Drop heavy deps (framer-motion, antd, @ant-design/icons) in favor of MUI + native APIs
  • Lazy-load GitHubCalendar inside bento preview; pause canvas animations and typewriter when off-screen or tab hidden
  • Convert 11 images to WebP + resize via scripts/optimize-images.js (sharp); delete 16 unused asset files
  • Redesign mobile drawer with numbered nav, dot indicator, social links footer

Bundle impact

Metric Before After Delta
main.js (raw) 658 KB 412 KB -37%
main.js (gzip) ~200 KB 132 KB -34%
Largest chunk (raw) 360 KB 82 KB -77%
build folder 10 MB 5.5 MB -45%
src/assets ~12 MB 3.4 MB -72%

Notable changes

  • ScrollReveal: framer-motion → IntersectionObserver + CSS transition
  • Contact: rebuilt with MUI TextField/Snackbar/AlertTitle, manual validation
  • GitHubPreview: defers react-github-calendar until card enters viewport, with skeleton placeholder matching the real 7×52 grid layout
  • ConstellationBackground, MatrixRain: pause via IntersectionObserver + visibilitychange
  • CursorGlow: rAF only runs while cursor moves
  • Home: typewriter pauses when section is off-screen or tab hidden
  • BentoCard: React.memo + useMemo handlers in BentoGrid
  • Hero avatar: <picture> with WebP source and fetchPriority="high" on img
  • All non-hero images: loading="lazy", decoding="async"
  • Mobile drawer: numbered list (01.06.) with monospace prefix, accent dot indicator, footer with email + location + social icons; removed border-left active style

Test plan

  • npm run dev — verify hero avatar loads as WebP, no layout shift on hero
  • Bento grid — click each card, drawer opens with correct lazy section
  • Bento GitHub card — calendar loads after card enters viewport (skeleton then real)
  • Contact form — submit empty → field errors; submit valid → success snackbar
  • Mobile (≤md) — open drawer, verify numbered nav, active dot indicator, footer links
  • Resize / scroll / switch tabs — animations pause when off-screen / hidden
  • npm run build — succeeds, bundle sizes match the table above

- drop framer-motion in favor of IntersectionObserver in ScrollReveal
- migrate Contact form from antd to MUI; remove antd and @ant-design/icons
- swap remaining @ant-design/icons in About to MUI equivalents
- lazy-load GitHubCalendar via IntersectionObserver in bento preview
- pause canvas animations (Constellation, MatrixRain) and Home typewriter
  when off-screen or when document is hidden
- only animate CursorGlow when cursor moves
- memoize BentoCard and stabilize handlers via useMemo
- delete 16 unused asset files (~9 MB)
- convert 11 images to WebP and resize via sharp script (~2 MB saved)
- preload hero avatar with fetchPriority=high inside <picture>
- add loading=lazy and decoding=async to non-hero images
- redesign mobile drawer: numbered nav, dot indicator, footer with email
  and social links; remove ChatGPT-like border-left highlight
- fix logo spacing between "Xuan" and "Anh"
- remove dead header.css and contact.css

Main bundle (raw) drops from 658 KB to 412 KB.
Largest chunk drops from 360 KB to 82 KB.
src/assets drops from ~12 MB to 3.4 MB.
@anhvuFE anhvuFE merged commit 08af620 into main May 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant