Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: prefetching pages on link hover #133

Open
blimpmason opened this issue Mar 3, 2018 · 4 comments
Open

Feature request: prefetching pages on link hover #133

blimpmason opened this issue Mar 3, 2018 · 4 comments

Comments

@blimpmason
Copy link

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
Copy link
Collaborator

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
Copy link
Author

blimpmason commented Mar 9, 2018

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
Copy link
Collaborator

@robinnorth What do you think?

@robinnorth
Copy link
Collaborator

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.

@BehindTheMath BehindTheMath added this to the 0.3.0 milestone Mar 13, 2018
@BehindTheMath BehindTheMath removed this from the 0.3.0 milestone Mar 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants