ruby-on-railshotwire-railsturbo

Rails with Hotwire/Turbo doing get requests on link hover


Using rails (7.1.3.2) and turbo-rails (2.0.4). For some reason, when ever I hover over any link in my app, a GET request is happening to the linked page. I check my inspector and there is a mouseenter event coming from turbo.es2017-esm.js:3135.

When I disable it, the GET requests don't happen.

Here is an example of a link I have

<%= link_to "Edit", edit_post_path(@post), class: "hover:text-black flex-none", data: { turbo_frame: :resource_frame } %>

Anyone know why this is happening and how I can stop it?


Solution

  • It's a new instaclick behavior in Turbo v8:
    https://github.com/hotwired/turbo/pull/1101

    You can disable it by adding a meta tag to your page:

    <meta name="turbo-prefetch" content="false">
    

    or data attribute to/around your links:

    <a href="/" data-turbo-prefetch="false">Home</a>
    
    <div data-turbo-prefetch="false">
      <a href="/">Home</a>
      ...
    </div>
    

    https://turbo.hotwired.dev/handbook/drive#prefetching-links-on-hover