Show HN: Prefetching based on mouse/keyboard predictions in JavaScript
1 BartSpaans 0 7/14/2025, 7:08:24 AM foresightjs.com ↗
I was looking for a way to make prefetching on my site faster. I had been using the classic onHover technique, but it started to feel limiting. So I switched to prefetching when elements enter the viewport. That worked, but over time I realized it was pretty wasteful. Just because something is visible doesn’t mean the user is going to interact with it.
That got me thinking about something in between. So I built ForesightJS in the open. Instead of prefetching onHover, it prefetches onIntent. If the mouse is clearly moving toward a link, it gets prefetched before the hover even happens. Same with keyboard navigation. If a user is a few tab stops away from a target, ForesightJS will kick in and prefetch it early.
I completely agree that this might not be for everyone, however if you do want to squeeze out those extra ms you might want to give it a try!
No comments yet