Ruby on Rails Turbolinks

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Introduction

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.

Remarks

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.



Got any Ruby on Rails Question?