Show HN: JavaScript predictive prefetching made easy. (open-source)

1 BartSpaans 0 8/3/2025, 9:06:13 AM foresightjs.com ↗
ForesightJS uses different prediction strategies depending on the device type. Foresight automatically detects mouse, pen, or touch input, and updates its strategy if the input method changes. You can use Foresight without any configuration!

Desktop prefetching strategies (all enabled by default):

- Mouse Trajectory - Analyzes cursor movement patterns to predict which links users are heading towards and prefetches content before they arrive

- Keyboard Navigation - Tracks tab key usage to prefetch when the user is N tab stops away from your registered element

- Scroll - Prefetches content when users scroll towards registered elements.

Touch device strategies (choose either one)

- onTouchStart - Captures the initial touch event to begin prefetching when users start interacting with registered elements

- Viewport Enter - Detects when registered elements enter the viewport and prefetches their content based on scroll behavior and visibility

Comments (0)

No comments yet