Your User's Next Move.
Already Fetched.
ForesightJS predicts user intent from mouse and keyboard cues to deliver instant navigation with zero waste.
Mouse Trajectory
Analyzes cursor movement patterns to predict which links users are heading towards and prefetches content before they arrive
Keyboard Navigation
Tracks tab key usage to prefetch when the user is N tab stops away from your registered element
Scroll
Prefetches content when users scroll towards registered elements, predicting which elements will be reached based on scroll direction
Viewport Enter
Detects when registered elements enter the viewport and prefetches their content based on scroll behavior and visibility
onTouchStart
Captures the initial touch event to begin prefetching when users start interacting with registered elements
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.
TIP: Try using Tab and Shift+Tab to navigate through the buttons above
INFO: Element overlays might lag behind since we use RAF and async techniques. This actually means the core package is optimized for performance.
import { ForesightManager } from 'js.foresight'
ForesightManager.initialize({
touchDeviceStrategy: "viewport",
tabOffset: 5
})
const myLink = document.querySelector('#my-link')
ForesightManager.instance.register({
element: myLink,
callback: () => {
console.log('User intent detected!')
}
})
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