pp

predictive-prefetch

A JavaScript client-side predictive prefetch solution for Webpack and SPAs. An alternative to Guess.js.

Showing:

Popularity

Downloads/wk

1

GitHub Stars

7

Maintenance

Last Commit

3mos ago

Contributors

1

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

Yes?

Categories

Readme

Predictive Prefetch js · GitHub license npm version PRs Welcome

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.

Why?

  • Speed up user future navigation.
  • 100% frontend AI solution.
  • Privacy, data is stored and kept locally.

FAQ

How it works?

  • 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.

Installation

# Yarn
yarn add predictive-prefetch

# NPM
npm install --save predictive-prefetch

Usage

import PredictivePrefetch from 'predictive-prefetch'

PredictivePrefetch();

Configuration

Predictive Prefetch includes options for:

  • assets: disable script and/or other resources monitoring.
  • urls: disable url intercepting.
  • predictor: calibrate prefetch minimum probability.

Default options

import PredictivePrefetch from 'predictive-prefetch'

const options = {
    assets: {
        scriptsDisabled: false, 
        resourcesDisabled: true,
        };
    urls: {
        disabled: false,
    };
    predictos: {
        minProbability: 0.7,
    };
};

PredictivePrefetch(options);

License

Predictive Prefetch is MIT licensed.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial