63

It's a constant headache when dealing with websockets, and it kills my performance in addition to adding bugs. Since ActionCable is the whole reason I upgraded I'd very much like to get rid of it completely.

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
GlyphGryph
  • 4,714
  • 4
  • 32
  • 43
  • 4
    caching of elements across pages has been the biggest headache for me. –  Jan 13 '18 at 19:23

5 Answers5

95

The following was copied from here. It's for Rails 4, but I believe the steps are the same.

  1. Remove the gem 'turbolinks' line from Gemfile.

  2. Remove the //= require turbolinks from app/assets/javascripts/application.js.

  3. Remove the two "data-turbolinks-track" => true hash key/value pairs from app/views/layouts/application.html.erb.

Edit: As of at least Rails 5 the last step should refer to "data-turbolinks-track" => "reload" as opposed to "data-turbolinks-track" => true. Thanks to @boddhisattva

Edit: As of at least Rails 4.2 you can generate a project without turbolinks to begin with. Just use something like this:

rails new my_app --skip-turbolinks

user664833
  • 18,397
  • 19
  • 91
  • 140
arjabbar
  • 6,044
  • 4
  • 30
  • 46
  • 1
    I tried removing turbolinks recently in a Rails 5 app(using Rails 5.0.0.1 to be exact) and I had to remove `data-turbolinks-track': 'reload'` as part of step 3 instead of `"data-turbolinks-track" => true`. I also see that they've specified the same key value pair - `"data-turbolinks-track" => "reload"` as part of the latest asset pipeline guides for Rails 5 here - http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets – boddhisattva Oct 12 '16 at 15:31
  • 1
    Important: there should be a step 4) -- In place of the `data-turbolinks-track` links just removed, add the first links found in the first box here: http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets . Simply removing the turbolink links causes javascript to stop working completely. – San Diago Apr 01 '17 at 18:27
  • this doesn't do it for me when deploying to a Heroku production server. – s2t2 Sep 26 '17 at 21:43
  • Did you have the change committed already? I'm unsure about Heroku, but for Elastic Beanstalk, which is similar, you need to commit your changes in Git before they will be deployed. – arjabbar Sep 27 '17 at 00:08
  • @s2t2 I'm having this same problem with production on Heroku, even after completely removing turbolinks from my app. Did you ever figure out the problem? – justinraczak Sep 21 '19 at 20:02
12

Removing //= require turbolinks from app/assets/javascripts/application.js seems to have done the trick.

I also removed both turbolinks references in app/views/layouts/application.html.erb

GlyphGryph
  • 4,714
  • 4
  • 32
  • 43
  • 1
    Removing/Commenting the `require` is the easiest way to disable TurboLinks without uninstalling it. Here is a way to 'comment' it: `//= xxxrequire turbolinks` – Chloe Apr 26 '17 at 18:55
11

If you are using Webpacker (Rails 5-6)

  • Delete this line from Gemfile and run bundle:

gem 'turbolinks', '~> 5'

  • Run yarn remove turbolinks

  • Delete this line from application pack file app/javascript/packs/application.js:

    require("turbolinks").start()

  • Remove any data-turbolinks data attributes from your html.

Change:

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>

to

<%= stylesheet_link_tag 'application', media: 'all' %>
<%= javascript_pack_tag 'application' %>
lunr
  • 5,159
  • 4
  • 31
  • 47
4

you can also do it when you create your rails application by using;

rails new app name --skip-turbolinks
Danny
  • 41
  • 2
2

Completely removing the turbolinks tags from application.html.erb might break CSS and JS. add this lines instead of the turbolinks if no CSS or JS is loaded:

<%= stylesheet_link_tag "application", media: "all" %>
<%= javascript_include_tag "application" %>
Ben Levi
  • 21
  • 4
  • Step 3 could be clarified, but it's saying to remove just the `"data-turbolinks-track" => "reload"` part (just that key/value pair), not the entire tag. – mltsy Sep 12 '18 at 19:25