Open blimpmason opened 6 years ago
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()
.
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.
@robinnorth What do you think?
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.
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.