react-magic
react-magic copied to clipboard
Ability to preload links on hover, or expose enough of an API for users to implement.
Hey,
Inspired by the preload-on-hover behaviour offered by https://github.com/dieulot/instantclick I'm wondering if it would make sense to either optionally allow such functionality here, or, if it might make sense to float enough of the API to allow something like this to be implemented.
With the existing implementation of load() I suppose this would entail attempting to throttle network calls performed on events such as hover, and modifying the cachebusting functionality so that only one network call is performed (maybe to be aware of existing query parameters too). If a response is already available, it can be used directly when handleStateChange()
is called.
As another option I suppose it'd be possible to do this via a service worker by leveraging the cache API, but I'd prefer to avoid this approach as it is more likely to go horribly wrong. That said, I am happy to contribute something along those lines if it'd be welcomed.
What do you think?
That's an interesting idea. Feel free to send a pull request if you like.