Skip to content

Commit bd18b4a

Browse files
committed
📝 Document mermaid lazy loading results
Added implementation notes and measured results to bundle analysis.
1 parent a612380 commit bd18b4a

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

BUNDLE_SIZE_ANALYSIS.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,3 +217,50 @@ ls -lh release/*.dmg
217217
This should get us from **176MB → ~120MB** with minimal risk.
218218

219219
Then evaluate if Phase 2/3 are worth the effort based on user feedback.
220+
221+
## Update: Mermaid Lazy Loading Implemented
222+
223+
**Date:** October 14, 2025
224+
225+
### Changes Made
226+
227+
1. **Lazy-loaded Mermaid component** - Converted to dynamic import pattern
228+
- Mermaid now loads only when first diagram is rendered
229+
- Follows same pattern as ai-tokenizer lazy loading
230+
231+
2. **Added manual chunk splitting** in vite.config.ts
232+
- Separated react/react-dom into `react-vendor` chunk
233+
- Separated react-syntax-highlighter into own chunk
234+
- Improves browser caching and parallel loading
235+
236+
### Results
237+
238+
**Bundle Size Reduction:**
239+
- Before: 2,833KB single bundle (all loaded on startup)
240+
- After: 2,292KB across multiple chunks (loaded on startup)
241+
- index: 1,534KB (main app code)
242+
- react-vendor: 138KB (React libraries)
243+
- syntax-highlighter: 620KB (code highlighting)
244+
- Mermaid: 482KB (now loads on-demand)
245+
246+
**Improvement:** 541KB (19%) reduction in startup bundle size
247+
248+
### Expected Performance Impact
249+
250+
- **Startup time:** 200-500ms faster initial load
251+
- **Memory:** Lower baseline memory usage when no diagrams present
252+
- **Network:** Mermaid only downloaded when actually needed
253+
- **Browser caching:** Better cache hit rates with separate vendor chunks
254+
255+
### Next Steps
256+
257+
For further optimization:
258+
1. Lazy load syntax-highlighter (currently still eager)
259+
2. Disable source maps in production (50MB savings in bundle)
260+
3. Replace mermaid with lighter alternative (for maximum impact)
261+
262+
### Notes
263+
264+
The warnings about chunk sizes >2000KB are expected and can be addressed
265+
with additional code splitting if needed. The current split already provides
266+
significant startup improvement while maintaining good DX.

0 commit comments

Comments
 (0)