Turbolinks provides an event listener that can be used to stop visits from occurring. Listen to the turbolinks:before-visit
event to be notified when a visit is about to commence.
In the event handler, you can use:
// pure javascript
event.data.url
or
// jQuery
$event.originalEvent.data.url
to retrieve the location of the visit. The visit can then be cancelled by calling:
event.preventDefault()
According to the official turbolinks docs:
Restoration visits cannot be canceled and do not fire turbolinks:before-visit.