instantpage / instant.page

Make your site’s pages instant in 1 minute and improve your conversion rate by 1%
https://instant.page
MIT License
6.04k stars 205 forks source link

Using with Turbolinks #52

Open frederikhors opened 4 years ago

frederikhors commented 4 years ago

I search in these issues for "turbolinks" work and nothing appears.

I wanna using instant.page with Turbolinks (https://github.com/turbolinks/turbolinks).

If I add:

<script src="//instant.page/2.0.0" type="module" defer integrity="sha384-D7B5eODAUd397+f4zNFAVlnDNDtO1ppV8rPnfygILQXhqu3cUndgHvlcJR2Bhig8"></script>

it works just on the first page I load.

What do you suggests to use with Turbolinks?

I can imagine to use some of the event in https://github.com/turbolinks/turbolinks#full-list-of-events, right?

frederikhors commented 4 years ago

Maybe an InstantPage.start() to call on every turbolinks:load event will be amazing.

What do you think?

dieulot commented 4 years ago

I’m planning to release a new version with a mechanism like InstantPage.start() (but by triggering an event instead of doing a function call, so that instant.page can be loaded asynchronously). Maybe that’ll solve it.

dieulot commented 4 years ago

I’ve talked privately with @dhh and he said he’s interested in bringing the just-in-time preloading mechanism into Turbolinks. I also plan to make an alternative to Turbolinks that uses them (in fact I already did so with InstantClick, but it lacks good documentation and a bunch of other things, I plan to reboot it). So maybe I won’t make instant.page compatible with Turbolinks in the next version, it will depend on ease of implementation, we shall see.

vitobotta commented 4 years ago

Hi @dieulot, so it's not possible to use instant.page with turbolinks now? Thanks

gpakosz commented 4 years ago

Interested in turbolinks + instant.page as well. What does it take to make the two work together?

phacks commented 4 years ago

I tried to get InstantPage to work with Rails to no avail, but managed to get InstantClick set up for a pretty similar result. If anybody’s interested in how I wrote a blog post about it: https://dev.to/phacks/the-rocky-road-to-implementing-link-prefetching-in-rails-oo0

mxkyb commented 3 years ago

Why does this not work? instant.pages EventListeners are bound to the document node, so the script shouldn't even need to get reinitialized on changes from turbolinks. And if the script is not at the end of the body it wouldn't be replaced by turbolinks.