Feature request: prefetching pages on link hover #133

Closed
opened 2018-03-03 17:49:34 -05:00 by blimpmason · 4 comments
blimpmason commented 2018-03-03 17:49:34 -05:00 (Migrated from github.com)

I'm coming over from Barba.js for the rock solid browser back/forward scroll restoration, but I'm missing Barba's prefetch functionality. Just curious if there's a workaround or a method I could call manually on hover that could start the pjax request before the user actually clicks the link. It can definitely make the transition feel a bit snappier.

Thanks! Really loving the flexibility of this library.

I'm coming over from Barba.js for the rock solid browser back/forward scroll restoration, but I'm missing Barba's prefetch functionality. Just curious if there's a workaround or a method I could call manually on hover that could start the pjax request before the user actually clicks the link. It can definitely make the transition feel a bit snappier. Thanks! Really loving the flexibility of this library.
BehindTheMath commented 2018-03-03 19:45:03 -05:00 (Migrated from github.com)

You can definitely implement it yourself. Make the request when the user hovers over the link, cache the response, then override
pjax.loadUrl() to first check if the response is cached. If it is, call pjax.loadContent() with the cached HTML. If not, call the regular pjax.loadUrl().

You can definitely implement it yourself. Make the request when the user hovers over the link, cache the response, then override `pjax.loadUrl()` to first check if the response is cached. If it is, call `pjax.loadContent()` with the cached HTML. If not, call the regular `pjax.loadUrl()`.
blimpmason commented 2018-03-09 10:10:05 -05:00 (Migrated from github.com)

Thanks for your response — do you know if there is any chance of adding this as an option in the future? I haven't had a chance to experiment with those methods yet, but I feel like it would be widely used if native prefetch support was built in. For now I'll have to stick with Barba rather than reinvent the wheel with a different library.

Thanks for your response — do you know if there is any chance of adding this as an option in the future? I haven't had a chance to experiment with those methods yet, but I feel like it would be widely used if native prefetch support was built in. For now I'll have to stick with Barba rather than reinvent the wheel with a different library.
BehindTheMath commented 2018-03-09 10:11:27 -05:00 (Migrated from github.com)

@robinnorth What do you think?

@robinnorth What do you think?
robinnorth commented 2018-03-12 08:21:04 -05:00 (Migrated from github.com)

Prefetch on mouseover/touchstart of links could be a very nice feature to have, for sure. It's probably worth adding it to a future milestone.

Prefetch on mouseover/touchstart of links could be a very nice feature to have, for sure. It's probably worth adding it to a future milestone.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: iLoveElysia/pjax#133