Added Lazy Loading
ForesightJS is designed to be lightweight. The entire library with all features is only ~32 KB minified. But now we go further with code splitting to minimize your initial bundle even more. Both handlers and predictors are lazy-loaded based on device type and enabled features:
Current chunk sizes:
| Chunk | Size | Loaded When |
|---|---|---|
| Core | ~14 KB | Always (initial load) |
| DesktopHandler + MousePredictor | ~15 KB | Desktop/mouse users |
| TouchDeviceHandler | ~2 KB | Touch device users |
| TabPredictor + tabbable | ~7 KB | enableTabPrediction: true
|
| ScrollPredictor | ~1.5 KB | enableScrollPrediction: true
|
| Touch predictors | ~1.5 KB | Touch device (based on strategy) |
Result:
- Touch devices load only ~19 KB (core + touch handler + touch predictor)
- Desktop with mouse-only loads ~32 KB (core + desktop handler + mouse predictor)
- Additional predictors (Tab, Scroll) load on-demand when enabled
js.foresight (V3.4.0)
- Added lazy loading to the predictors.
- Added
loadedModulestogetManagerData()
js.foresight-devtool (V1.4.0)
- Update devtools to display loaded modules in state log