ForesightJS  by spaansba

Predicts user intent for optimized prefetching

created 2 months ago
896 stars

Top 41.3% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

ForesightJS is a lightweight JavaScript library designed to predict user intent based on mouse and keyboard navigation, enabling proactive prefetching to enhance perceived website performance. It targets web developers seeking to optimize user experience by intelligently triggering resource loads before explicit user interaction, benefiting both mouse and keyboard users.

How It Works

ForesightJS analyzes cursor trajectory, scroll events, and keyboard tab sequences to predict which elements a user is likely to interact with. This predictive approach allows developers to initiate resource loading (e.g., prefetching) during the optimal "when" window, bridging the latency gap of traditional hover-based prefetching and avoiding the waste of viewport-based prefetching.

Quick Start & Requirements

  • Install: pnpm add js.foresight, npm install js.foresight, or yarn add js.foresight
  • Requirements: Browser environment.
  • Documentation: https://foresightjs.org/ (implied by framework integration links)

Highlighted Details

  • Solves latency in hover-based prefetching by predicting intent 80ms ahead.
  • Avoids wasteful prefetching common in viewport-based strategies.
  • Includes keyboard navigation analysis, improving accessibility.
  • Offers a visual debugging mode for tuning predictions.

Maintenance & Community

  • Integrations available for Next.js and React Router.
  • Contributions for new framework integrations are welcomed.
  • Future plans include decoupling the debugger and offloading processing to improve performance and accessibility.

Licensing & Compatibility

  • License: Not explicitly stated in the README.
  • Compatibility: Framework agnostic, with specific integrations for Next.js and React Router.

Limitations & Caveats

The library does not register elements for touch devices or users on limited connections (2G/data-saver mode), though it provides properties to implement fallback strategies. The specific license is not mentioned, which may impact commercial use.

Health Check
Last commit

19 hours ago

Responsiveness

Inactive

Pull Requests (30d)
4
Issues (30d)
2
Star History
917 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.