guess
🔮 Libraries & tools for enabling Machine Learning driven user-experiences on the web
Guess.js is a JavaScript library that speeds up website navigation by automatically prefetching the pages users are most likely to visit next, driven by real traffic patterns pulled from your Google Analytics account.
Guess.js is a set of JavaScript libraries that makes websites load pages faster by predicting where a user is likely to navigate next and quietly fetching those pages in the background before the user clicks. The prediction is based on real traffic patterns pulled from Google Analytics: if analytics shows that 60% of visitors who land on your homepage then go to your pricing page, Guess.js will prefetch the pricing page automatically for each new visitor on the homepage.
The project has two main integration paths. If you use webpack to bundle your JavaScript, there is a webpack plugin called GuessPlugin that connects to your Google Analytics account, reads the navigation data, and configures your build so that JavaScript bundles for likely next pages are loaded ahead of time. For sites that do not use webpack, there is a separate workflow that adds a small client-side script to your site, which asks a server for the most probable next URL and then prefetches it.
The core packages are split into three modules. One module fetches and structures the navigation data from the Google Analytics API. A second module parses JavaScript framework routes so the tool understands how pages map to code bundles. The third is the webpack plugin itself, which brings the other two together and exposes configuration options for tuning how aggressively pages are prefetched based on connection speed and probability thresholds.
The problem Guess.js addresses is that prefetching is underused on the web because it traditionally required developers to manually study analytics and hardcode prefetch hints. Those hints go stale as traffic patterns change. Guess.js automates the analysis and keeps the prefetch decisions in sync with current data.
The project is labeled alpha in the README. It requires a Google Analytics account with existing traffic data to drive its predictions.
Where it fits
- Speed up page navigation on a website by automatically prefetching the most likely next pages based on real Google Analytics traffic data.
- Add predictive prefetching to a webpack project using GuessPlugin without manually writing prefetch hints that go stale.
- Implement server-side next-page prediction for a non-webpack site using the Guess.js client-side script.
- Keep prefetching decisions automatically up to date as traffic patterns change, with no manual hint maintenance.