What is ForesightJs?
ForesightJS is a free and open-source fully typesafe JavaScript library that helps predict what users are likely to do next by analyzing their mouse movements and keyboard navigation. It lets developers prefetch data ahead of time based on these predictions, instead of waiting for actions like clicks or hovers. This makes websites feel faster and more responsive for both mouse and keyboard users, and is less wasteful than prefetching content as soon as it enters the viewport.
Cursor Prediction
Prefetch data based on where the users cursor is heading, not where it is currently hovering
Keyboard Prediction
Prefetch data when the user is N tab stops away from your element. Also works for shift-tabbing.
Fully Customizable
Configure how aggressively predictions are made, adjust hit areas around elements and much more.
Debug Mode
Built-in visual debugging with trajectory visualization, hit area overlays, and interactive control panel for tuning configurations in real-time.
Note: The interactive demos on this page work only on desktop with a mouse and keyboard. You can still read the documentation on mobile, but to fully experience the ForesightJS mouse trajectory prediction, please try the demos on a desktop device.
Playground
Each button simulates a 300ms server response delay to demonstrate real-world fetching scenarios. To explore all settings you can open the debugger in the bottom-right corner while debug mode is on. To experience the app as an end user would, turn off debug mode.