Keyboard & Mouse
Mouse Trajectory
Analyzes cursor movement to predict which links a user is heading towards, prefetching before they arrive.
Keyboard Navigation
Tracks tab key usage to prefetch once the user is N tab stops away from your registered element.
Scroll
Predicts which elements will be reached from scroll direction and prefetches them on the way.
Touch Devices
Viewport Enter
Detects when registered elements enter the viewport and prefetches based on scroll and visibility.
onTouchStart
Captures the initial touch to begin prefetching the moment a user starts interacting.
Playground
See predictions trigger in real-time with the official Development Tools. Move your mouse, scroll or use Tab navigation to experience intent detection.
Note: ForesightJS now offers full touch device support (mobile/pen) as of version 3.3.0 in the form of Viewport and onTouchStart predictions! However, to fully see how Foresight actually works and experience the complete mouse trajectory prediction system, you need to be on desktop. You can read the documentation and learn more about mobile support here.
Traditional Prefetching
ForesightJS Prefetching
Quick Start
Start predicting user intent in under 5 minutes. Zero complex setup.
import { ForesightManager } from 'js.foresight'const myButton = document.querySelector('#my-button')ForesightManager.instance.register({element: myButton,callback: () => console.log("prefetch logic here"),})
What you get:
- Mouse prediction: Detect cursor trajectory towards elements
- Keyboard support: Detect user tabbing towards elements
- Scroll Prediction: Detect scrolling towards a fetchable element
- Touch device support: Full touch device support (mobile/pen)
- Performance: No polling, no reflows, event-driven architecture
- TypeScript: Full type safety out of the box