100% client side, out of the box predictive prefetch solution for webpack and modern SPAs, based on alz-predictor.
-
Webpack: Learn, predict and prefetch JavaScript modules or chunks and other supported assets in runtime.
-
SPA: Predict and prefetch user's next Route or URL, e.g: from React Router.
-
Unlike Guess.js, Predictive Prefetch doesn't require any third party data analytics sources.
- Speed up user future navigation.
- 100% frontend AI solution.
- Privacy, data is stored and kept locally.
-
Monitor any mutation change in the document object looking for JavaScript tags and other supported assets.
-
Intercept history pushState looking for changes in routes.
-
Train ALZ Predictor and predict next asset or route.
-
Add link tag with prefetch rel for the previous prediction.
# Yarn
yarn add predictive-prefetch
# NPM
npm install --save predictive-prefetch
import PredictivePrefetch from 'predictive-prefetch'
PredictivePrefetch();
Predictive Prefetch includes options for:
- assets: disable script and/or other resources monitoring.
- urls: disable url intercepting.
- predictor: calibrate prefetch minimum probability.
import PredictivePrefetch from 'predictive-prefetch'
const options = {
assets: {
scriptsDisabled: false,
resourcesDisabled: true,
};
urls: {
disabled: false,
};
predictos: {
minProbability: 0.7,
};
};
PredictivePrefetch(options);
Predictive Prefetch is MIT licensed.