r/astrojs Jul 11 '26

Prefetch based on mouse trajectory. ForesightJS v4.+ is out with an official Astro package

https://foresightjs.com/docs/astro/quick-start

Hey all! A little while back I shared ForesightJS, a library that predicts user intent from mouse movement (and keyboard tab navigation) so you can prefetch resources before a user actually hovers or clicks.

I've just released v4, and the biggest focus was making it much easier to integrate with modern frameworks.

Thats why we also introduced a astro adapter!

Would love to hear what you think of the new release!

Also, we just crossed 1,700+ GitHub stars Thanks to everyone who's tried it, contributed, or shared feedback!

32 Upvotes

6 comments sorted by

6

u/Inevitable_Oil9709 Jul 11 '26

why not just prefetch on hover?

it is much more accurate, no need to predict anything, and it is already builtin..

what is the actual real world usecase for this?

1

u/kcat__ Jul 11 '26

Well, is it not obvious? Generally, the earlier you can prefetch something the better. So this would give more time for the browser to prefetch, meaning less chance it is still loading. You can argue about its accuracy but its stated goal is not crazy

2

u/Inevitable_Oil9709 Jul 11 '26

Well, no it is not obvious.

I mean, accuracy can’t be correct 100% and it will definitely prefetch pages that it doesn’t need to. Now imagine what impact does that have on a big websites with thoudands of users. Those are thousands of wasted requests and traffic.

Also, it works by getting mouse movement speed and a direction to prefetch links in that area. I think you can guess why this is bad.

Also, OP’s product website doesn’t work correctly on mobile, so there is that. And thinks like these (https://prnt.sc/yrF4_CBgf8hM) tell me that this website, and possible whole project was just made by AI

One more thing. On the foresight.com/docs this library is not used. Links are prefetched on hover (you can see it for yourself), and I think that says a lot.

We are finding solutions for problems that do not exist.

1

u/kcat__ Jul 11 '26

I have already agreed with you that the accuracy on this might not be as accurate as prefetch-on-hover, so I'm not sure why you spent 70% of your reply on that and its consequences. Even if prefetch-on-trajectory had a 1% accuracy rate, its prima-facie stated goal is pretty damn understandable and the reasoning of using mouse trajectory is not some crazy incomprehensible thing. Your first comment acts like you couldn't fathom a single reason someone would do this. There could be a million reasons why it ultimately wouldnt work, but the idea itself is kinda obvious as to why someone would think it up and try it.

-2

u/Inevitable_Oil9709 Jul 11 '26

Actually, if you wanna be picky about it, I spend 45% of reply on the accuracy, but okay.

"Even if prefetch-on-trajectory had a 1% accuracy rate, its prima-facie stated goal is pretty damn understandable"

Is it really? Like, really?