Skip to content

Optimize frontend bundle size with code splitting and tree shaking #73

Description

@jobbykings

Description

Heavy dependencies like Three.js (@react-three/fiber, three), TensorFlow.js, Pyodide, and D3 significantly increase bundle size. Implement dynamic imports, route-based code splitting, and lazy loading for non-critical features (AR/VR, 3D lab, metaverse, BCI) to improve initial load time.

Files to Modify

  • frontend/src/app/layout.tsx — Dynamic import config
  • frontend/next.config.js — Bundle analyzer config
  • Component files with heavy deps — Convert to dynamic imports
  • frontend/src/components/ARVR/ — Lazy load all VR components
  • frontend/src/components/Metaverse/ — Lazy load 3D components
  • frontend/src/components/Lab/ — Lazy load lab sim

Definition of Done

  • All non-critical feature modules use next/dynamic with ssr: false
  • Initial JS bundle < 200KB (gzipped) for landing page
  • Route-based code splitting for all /app routes
  • Three.js, TensorFlow.js, Pyodide loaded only when needed
  • Bundle analyzer shows no duplicate dependencies
  • Lighthouse performance score ≥ 80 on mobile

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions