PERFORMANCE QUICK REFERENCE - nself-org/nchat GitHub Wiki
Version: 0.9.1 Last Updated: February 9, 2026
# Analyze bundle sizes (visual)
pnpm build:analyze
# Run Lighthouse audit
pnpm lighthouse
# Generate bundle report
tsx scripts/analyze-bundle.ts
# Type check (performance impact)
pnpm type-check
# Build for production
pnpm build| Metric | Value | Status |
|---|---|---|
| Shared Bundle | 103 KB | ✅ Excellent |
| Public Pages | 104-221 KB | ✅ Good |
| Chat Pages | 200-284 KB | ✅ Good |
| Settings Pages | 466-478 KB | ❌ Needs work |
| Admin Pages | 164-415 KB | |
| API Routes | 1.45 KB | ✅ Excellent |
-
Lazy Load Recharts
import { LazyAnalyticsCharts } from '@/lib/performance/lazy-loader' // Use in admin analytics pages
-
Code Split Admin Routes
// Already supported by Next.js App Router // Keep admin pages in separate route groups
-
Lazy Load GDPR Tools
const LazyGDPR = dynamic(() => import('@/components/gdpr-tools'), { loading: () => <Skeleton />, ssr: false })
-
Lazy Load TipTap Editor
import { LazyRichTextEditor } from '@/lib/performance/lazy-loader'
-
Lazy Load Emoji Picker
import { LazyEmojiPicker } from '@/lib/performance/lazy-loader'
import dynamic from 'next/dynamic'
const HeavyComponent = dynamic(() => import('./HeavyComponent'), {
loading: () => <div>Loading...</div>,
ssr: false
})import { measureFunction } from '@/lib/performance/performance-monitor'
const result = await measureFunction('my-operation', async () => {
// Your code here
return data
}, true) // true = log to consoleimport { checkPerformanceBudget } from '@/lib/performance/performance-monitor'
// Returns true if within budget
const isGood = checkPerformanceBudget()import { prefetchCallComponents } from '@/lib/performance/lazy-loader'
<button
onMouseEnter={prefetchCallComponents}
onClick={startCall}
>
Start Call
</button>| File | Purpose |
|---|---|
/docs/PERFORMANCE-AUDIT.md |
Complete audit report |
/docs/BUNDLE-ANALYSIS.md |
Bundle size breakdown |
/docs/PERFORMANCE-OPTIMIZATIONS.md |
Implementation guide |
/src/lib/performance/lazy-loader.ts |
Lazy loading utilities |
/src/lib/performance/performance-monitor.ts |
Runtime monitoring |
/.lighthouserc.js |
Lighthouse CI config |
/scripts/analyze-bundle.ts |
Bundle analysis script |
- Lazy load heavy components (>50KB)
- Use dynamic imports for admin/settings
- Implement virtual scrolling for long lists
- Memoize expensive calculations
- Use React.memo for pure components
- Monitor bundle sizes in CI/CD
- Profile with React DevTools
- Check Web Vitals regularly
- Import entire libraries at top level
- Load all features upfront
- Ignore bundle size warnings
- Skip lazy loading for charts/editors
- Use heavy animations on every render
- Forget to clean up event listeners
- Ignore memory leaks
- Skip performance budgets
| Metric | Target | Current |
|---|---|---|
| LCP | < 2.5s | ✅ Monitored |
| FID | < 100ms | ✅ Monitored |
| CLS | < 0.1 | ✅ Monitored |
| FCP | < 1.8s | ✅ Monitored |
| TTFB | < 600ms | ✅ Monitored |
| Resource | Budget | Enforcement |
|---|---|---|
| JavaScript | < 300KB | Lighthouse CI |
| CSS | < 50KB | Lighthouse CI |
| Images | < 500KB | Lighthouse CI |
| Fonts | < 100KB | Manual |
| Total | < 1MB | Manual |
- Run
pnpm build:analyze - Identify largest chunks
- Lazy load heavy components
- Code split routes
- Check Web Vitals
- Run Lighthouse audit
- Profile with Chrome DevTools
- Check network waterfall
- Check console for warnings
- Use performance monitor
- Look for memory leaks
- Profile with Chrome DevTools
- Use React Profiler
- Check component re-renders
- Add memoization
- Optimize expensive calculations
-
Documentation:
/docs/PERFORMANCE-OPTIMIZATIONS.md -
Audit Report:
/docs/PERFORMANCE-AUDIT.md -
Bundle Analysis:
/docs/BUNDLE-ANALYSIS.md -
Task Report:
/TASK-136-PERFORMANCE-REPORT.md
Generated: February 9, 2026 Next Review: March 9, 2026