Ruby on Rails Turbolinks


Turbolinks is a javascript library that makes navigating your web application faster. When you follow a link, Turbolinks automatically fetches the page, swaps in its <body>, and merges its <head>, all without incurring the cost of a full page load.


As a rails developer, you will likely interact minimally with turbolinks during your development. It is, however, an important library to be familiar with because it can be the cause of some hard-to-find bugs.

Key takeaways:

  • Bind to the turbolinks:load event instead of the document.ready event
  • Use the data-turbolinks-false attribute to disable turbolink functionality on a per-link basis.
  • Use the data-turbolinks-permanent attribute to persist elements across page loads and to avoid cache-related bugs.

For a more in-depth treatment of turbolinks, visit the official github repository.

Credit for much of this documentation goes to the folks who drafted the turbolinks documentation on the github repository.