What is ForesightJS and how does it work?
mainForesightJS is a lightweight JavaScript library designed to predict user intent, allowing you to prefetch content before a user explicitly requests it.
It solves the problem of when to fetch data by analyzing user behavior such as mouse trajectory and tab navigation. This allows for proactive loading that works out of the box for both desktop and mobile devices.
To use ForesightJS, you follow a simple mental model:
- ForesightJS handles the 'When': It predicts the optimal moment to start fetching based on intent.
- You handle the 'What' and 'How': You provide a
callbackfunction when registering an element that defines which resource to load and which loading/caching strategy to use.