⚡ Bolt: Lazy load exercises and notebooks#376
Conversation
Deferred the parsing of exercises and solution notebooks until they are actually accessed. This prevents blocking the main thread during initial application load with regex and JSON parsing operations for 100+ lessons. Co-authored-by: saint2706 <45678566+saint2706@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR reduces application startup work by deferring expensive exercise extraction and notebook JSON parsing in src/utils/contentLoader.ts until the data is actually requested by the UI.
Changes:
- Lazily compute and freeze the exercises collection on first
getAllExercises()call instead of at module import. - Lazily compute and freeze the notebooks collection on first
getAllNotebooks()call, and routegetNotebook()through the lazy accessor. - Document the performance learning/action in
.Jules/bolt.md.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/utils/contentLoader.ts |
Replaces eager module-scope parsing with cached lazy initialization for exercises and notebooks. |
.Jules/bolt.md |
Adds an entry documenting the eager parsing cost and the lazy-load refactor. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
💡 What: Refactored
src/utils/contentLoader.tsto lazy loadallExercisesandnotebooks. These large data structures are now computed on first access (viagetAllExercisesandgetAllNotebooks) rather than eagerly on module import.🎯 Why: Eager parsing of 100+ markdown files (via regex) and solution notebooks (via
JSON.parse) was blocking the main thread during application startup.📊 Impact: Deferred ~8-10ms of parsing work (in test environment) from the critical startup path. This scales with the number of lessons and complexity of content, ensuring faster Time to Interactive.
🔬 Measurement: Verified with a benchmark script that showed import time no longer triggers the parsing logic.
PR created automatically by Jules for task 9427291637281753950 started by @saint2706