Deferred Bootstrap
"/home/yossef/notes/git/projects/maplibra/decisions/Deferred Bootstrap.md"
path: maplibra/decisions/Deferred Bootstrap.md
- **fileName**: Deferred Bootstrap
- **Created on**: 2026-06-16 00:48:42
Deferred Bootstrap
Purpose: Why routing, search, and debug layers load lazily after the first floor render.
Related: ../Home.md, ../Architecture.md, ../modules/Bootstrap System.md, ../flows/Startup Sequence.md
Decision
Load heavy subsystems (routing controller, search box, debug layers) only after the map is interactive and the first floor is rendered.
Rationale
- Time-to-first-render is the critical metric for user perception. The map should be visible within seconds.
- Routing graph loading can take 1-3 seconds for large buildings. Blocking startup on this would make the app feel slow.
- Search box is not needed immediately — users typically look at the map first.
- Debug layers are developer-only and should never affect production startup.
- Network variability — outdoor routing APIs may be slow or unavailable; deferring prevents timeout anxiety.
Implementation
bootstrap-routing.jsuses dynamicimport()to lazy-loadpathfinding-controller.jsbootstrap-search.jsuses dynamicimport()to lazy-loadSearchBox.jsbootstrap-debug.jsuses dynamicimport()to lazy-load debug layer modulesscript.jsqueues post-render tasks viascheduleStartupTask()with idle schedulingPathfindingControlleris only initialized when the user first interacts with routing (clicks map, searches, etc.)
Tradeoffs
- Pro: Faster startup, better perceived performance, lower initial bundle size
- Con: First route computation may have a slight delay if the routing graph is still loading
- Mitigation:
warmGraphResources()preloads the graph in the background after idle
When It Was Made
Phase 5+ of the product hardening effort. The deferred bootstrap pattern was added to support large buildings with heavy routing graphs.
Related Notes
-
docs/routing-rollout.mdcontinue:[[]]
before:[[]]