Kasperi
Kasperi

Reputation: 863

Turbolinks not working - instead loads page twice

So, in my Rails 4 app I have Turbolinks gem.

//= require jquery.js 
//= require jquery.turbolinks
//= require turbolinks

However, something seems to be wrong. Isn't the point of Turbolinks that you don't have to load all the jquery/css/asset pipeline other than once at start? Well, that doesn't seem to happen, and it proceeds to load all jquery each time new page is requested, and what's more, it even makes each page load twice. Such as:

Started GET "/" for ip at 2014-01-21 18:55:35 +0200
*Loads bunch of stuff here*

Started GET "/" for ip at 2014-01-21 18:55:35 +0200
*Loads bunch of stuff here*

Started GET "/assets/jquery.js"
Started GET "/assetsjquery_ujs" 
Started GET "/assets/litecarousel"
Et cetera...

When I comment out //= require turbolinks the console seems to show only one page load, which is normal. What could be the cause of this?

I have many jquery functions with $(document).ready, but with jquery.turbolinks this should be just fine.

// EDIT: Tested out a few things and it seems it's a bug related to Chrome. Works good on Firefox. Also, my version of the gem is v.2.2.0.

Upvotes: 2

Views: 1833

Answers (1)

GMA
GMA

Reputation: 6096

Have you put the line <%= javascript_include_tag ... %> between the <body> tags of your page instead of in the <head>? I was getting all kinds of weird errors from Turbolinks once and this was the cause.

Upvotes: 2

Related Questions