Settings

Theme

Show HN: Prefetching based on mouse/keyboard predictions in JavaScript

foresightjs.com

2 points by BartSpaans 5 months ago · 0 comments · 1 min read

Reader

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.

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection