BUNDLE ANALYSIS - nself-org/nchat GitHub Wiki
Date: February 9, 2026 Version: 1.0.0 Build: Next.js 15.5.10
✅ Build Status: Successful
✅ Shared Bundle: 103 KB (well optimized)
| Metric | Value | Status |
|---|---|---|
| Shared Bundle | 103 KB | ✅ Excellent |
| Largest Route | 478 KB (Admin Privacy) | |
| Total Routes | 200+ | ✅ Good |
| API Routes | ~150 | ✅ Minimal |
| Average Page Size | ~15-20 KB | ✅ Good |
| Average First Load | ~200-250 KB |
Total Shared: 103 KB
chunks/91494-975eac886ac5f165.js 46.2 KB (Core React/Next.js)
chunks/a87be097-d4f145ea238f5bd3.js 54.2 KB (Apollo/GraphQL)
other shared chunks (total) 2.54 KB (Utilities)
Analysis:
- ✅ Well optimized at 103KB total
- ✅ Core framework (React 19 + Next.js 15) at 46KB is excellent
- ✅ Apollo/GraphQL at 54KB is reasonable for real-time app
- ✅ Minimal utility overhead (2.5KB)
| Route | Size | First Load | Issue |
|---|---|---|---|
| /settings/privacy/gdpr | 24.5 KB | 478 KB | Large GDPR compliance UI |
| /settings/notifications | 8.88 KB | 471 KB | Notification preferences |
| /settings/privacy/location | 6.64 KB | 477 KB | Location settings |
| /settings/account | 5.72 KB | 468 KB | Account management |
| /settings/data | 3.33 KB | 469 KB | Data management |
| /settings/keyboard | 5.17 KB | 468 KB | Keyboard shortcuts |
| /settings/security | 2.44 KB | 468 KB | Security settings |
| /settings/profile | 4.57 KB | 467 KB | Profile settings |
| /settings/privacy | 4.61 KB | 467 KB | Privacy settings |
| /settings | 3.56 KB | 466 KB | Settings hub |
| /admin/advanced | 30.2 KB | 415 KB | Advanced admin tools |
| /admin/channels/[id] | 8.92 KB | 394 KB | Channel admin |
| /admin | 5.63 KB | 378 KB | Admin dashboard |
| /admin/moderation | 17 KB | 364 KB | Moderation queue |
| /admin/bots/manage | 21.9 KB | 339 KB | Bot management |
Issue: All settings pages load 466-478KB on first load Cause: Shared settings layout with heavy form libraries
Components Contributing:
- React Hook Form (~25KB)
- Zod validation (~15KB)
- Form UI components (~30KB)
- Settings navigation (~20KB)
- Total overhead: ~90KB + shared 103KB = ~193KB base
Individual page costs:
- GDPR compliance: +285KB (GDPR tools, export, privacy controls)
- Notifications: +278KB (Notification manager, preferences)
- Location: +284KB (Maps, geocoding, location privacy)
- Account/Security/Profile: ~275KB each
Recommendations:
- ✅ Lazy load form validation - Load Zod schemas on demand
- ✅ Code split settings sections - Don't load all settings upfront
- ✅ Lazy load GDPR tools - Only load when user clicks "Export Data"
- ✅ Virtualize settings list - Don't render all settings at once
Potential Savings: ~150-200KB per settings page
Issue: Admin pages range from 164KB to 415KB Cause: Admin dashboard includes charts, tables, analytics
Largest Admin Routes:
- /admin/advanced: 415KB (Advanced configuration tools)
- /admin/channels/[id]: 394KB (Channel management)
- /admin: 378KB (Dashboard with charts)
- /admin/moderation: 364KB (Moderation queue)
- /admin/bots/manage: 339KB (Bot builder)
Components Contributing:
- Recharts library: ~300KB (for analytics charts)
- Tables and data grids: ~50KB
- Admin navigation: ~30KB
- Dashboard widgets: ~40KB
Recommendations:
- 🔴 Lazy load Recharts - Critical! Load only when charts are visible
- ✅ Code split admin by section - Separate bundles for moderation, analytics, bots
- ✅ Lazy load bot builder - Only load when creating/editing bots
- ✅ Defer non-critical widgets - Load charts in background
Potential Savings: ~200-250KB per admin page
Well Optimized Routes:
- /login: 214KB
- /signup: 214KB
- /auth/signin: 210KB
- /auth/signup: 210KB
- /_not-found: 104KB
Analysis: These are well optimized. No action needed.
Chat Routes:
- /chat: 214KB
- /chat/channel/[slug]: 284KB
- /activity: 204KB
- /people: 313KB
Analysis: Reasonable for real-time chat app. Could optimize further.
Recommendations:
- ✅ Lazy load TipTap editor - Load rich text editor on focus
- ✅ Lazy load emoji picker - Load when user clicks emoji button
- ✅ Virtual scrolling - Already implemented ✓
Potential Savings: ~30-50KB
All API routes are extremely optimized at 1.45KB each. No action needed.
-
Lazy Load Recharts (~300KB savings)
const LazyChart = dynamic(() => import('recharts'), { loading: () => <ChartSkeleton />, ssr: false })
-
Code Split Admin Routes (~200KB savings per route)
// Separate admin bundle // Already possible with Next.js App Router
-
Lazy Load Settings Forms (~150KB savings)
const LazyGDPRTools = dynamic(() => import('@/components/settings/gdpr-tools'), { loading: () => <Skeleton />, ssr: false })
- Lazy Load TipTap Editor (~150KB savings)
- Lazy Load Emoji Picker (~80KB savings)
- Optimize Settings Layout (~100KB savings)
- Defer Admin Widgets (~50KB savings)
- Implement Virtual Scrolling (Already done ✓)
- Optimize Form Libraries (Consider lighter alternatives)
- Bundle Size Monitoring (Add to CI/CD)
| Resource | Current | Target | Status |
|---|---|---|---|
| Shared Bundle | 103 KB | < 150 KB | ✅ Excellent |
| Public Pages | 104-221 KB | < 250 KB | ✅ Good |
| Chat Pages | 200-284 KB | < 300 KB | ✅ Good |
| Settings Pages | 466-478 KB | < 300 KB | ❌ Exceeds |
| Admin Pages | 164-415 KB | < 350 KB | |
| API Routes | 1.45 KB | < 10 KB | ✅ Excellent |
| # | Route | Size | First Load | Type |
|---|---|---|---|---|
| 1 | /settings/privacy/gdpr | 24.5 KB | 478 KB | ○ Static |
| 2 | /settings/privacy/location | 6.64 KB | 477 KB | ○ Static |
| 3 | /settings/notifications | 8.88 KB | 471 KB | ○ Static |
| 4 | /settings/data | 3.33 KB | 469 KB | ○ Static |
| 5 | /settings/account | 5.72 KB | 468 KB | ○ Static |
| 6 | /settings/keyboard | 5.17 KB | 468 KB | ○ Static |
| 7 | /settings/security | 2.44 KB | 468 KB | ○ Static |
| 8 | /settings/privacy | 4.61 KB | 467 KB | ○ Static |
| 9 | /settings/profile | 4.57 KB | 467 KB | ○ Static |
| 10 | /settings | 3.56 KB | 466 KB | ○ Static |
| 11 | /admin/advanced | 30.2 KB | 415 KB | ○ Static |
| 12 | /admin/channels/[id] | 8.92 KB | 394 KB | ƒ Dynamic |
| 13 | /admin | 5.63 KB | 378 KB | ○ Static |
| 14 | /admin/moderation | 17 KB | 364 KB | ○ Static |
| 15 | /admin/bots/manage | 21.9 KB | 339 KB | ○ Static |
| 16 | /admin/bots | 17.1 KB | 335 KB | ○ Static |
| 17 | /meetings/schedule | 3.58 KB | 335 KB | ○ Static |
| 18 | /meetings/[id] | 2.34 KB | 334 KB | ƒ Dynamic |
| 19 | /people | 22.6 KB | 313 KB | ○ Static |
| 20 | /admin/webhooks | 23.7 KB | 308 KB | ○ Static |
Current: All admin pages share same bundle Proposed: Split into sections
Admin Core (150KB)
├── Admin Analytics (150KB) - Recharts + charts
├── Admin Moderation (100KB) - Moderation tools
├── Admin Bots (80KB) - Bot builder
└── Admin Settings (50KB) - Configuration
Savings: 200-250KB for non-admin users
Current: All settings share heavy form bundle Proposed: Split by category
Settings Core (100KB)
├── Privacy Tools (150KB) - GDPR, location
├── Notifications (120KB) - Notification manager
├── Account/Security (100KB) - Auth settings
└── Appearance/Theme (50KB) - UI customization
Savings: 150-200KB per settings page
Current: All features load upfront Proposed: Load on demand
// Load only when needed
const CallWindow = lazy(() => import('@/components/calls'))
const VideoEditor = lazy(() => import('@/components/video'))
const AdvancedSearch = lazy(() => import('@/components/search/advanced'))Savings: 300-400KB for users who don't use features
- ✅ Implement lazy-loader.ts utility (DONE)
- 🔴 Lazy load Recharts in admin pages
- 🔴 Code split settings pages
- 🔴 Lazy load GDPR compliance tools
- 🟡 Implement progressive loading for admin dashboard
- 🟡 Optimize form libraries in settings
- 🟡 Add bundle size monitoring to CI/CD
- 🟡 Configure Lighthouse CI (DONE - .lighthouserc.js created)
- 🟢 Evaluate lighter alternatives for heavy libraries
- 🟢 Implement service worker for caching
- 🟢 Set up performance dashboard
- 🟢 Regular bundle size audits
- ✅ Bundle Analyzer:
pnpm build:analyze - ✅ Lighthouse CI:
pnpm lighthouse - ✅ Bundle Analysis Script:
tsx scripts/analyze-bundle.ts - ✅ Web Vitals Tracking: Built into app
# .github/workflows/performance.yml
- name: Bundle Size Check
run: pnpm build:analyze
- name: Lighthouse CI
run: pnpm lighthouseOverall Assessment: 🟡 Good with room for improvement
Strengths:
- ✅ Excellent shared bundle optimization (103KB)
- ✅ Well-optimized API routes (1.45KB each)
- ✅ Good core page sizes (104-221KB)
- ✅ Proper code splitting infrastructure
Areas for Improvement:
⚠️ Settings pages are heavy (466-478KB)⚠️ Some admin pages exceed budget (415KB)⚠️ Charts library not lazy loaded
Expected Impact of Optimizations:
- Settings pages: 466KB → ~280KB (39% reduction)
- Admin pages: 415KB → ~250KB (40% reduction)
- Overall app: ~25-30% bundle size reduction
Next Review: March 9, 2026 Generated: February 9, 2026 Tool: scripts/analyze-bundle.ts