Turbolinks is a Rails feature, which is available as a gem and starting from rails 4 is automatically enabled in each new rails app.
It is intended to speed up navigation between the pages of your application.
It works by intercepting all link clicks that would navigate to a page within the app, and instead of loading the whole page via HTML it makes the request via AJAX, replacing the body with the received content.
turbolinks gem to your Gemfile.
One of my favourite benefits - no server side changes need to be made to make it work!
Okay, what about routing? Since the browser doesn't make HTML requests to the server, but is rather just an AJAX, how should the routes work? The answer is simple - as expected. Back and forward buttons work as usual, and there is nothing additional that you need to define.
One of the things missing from the first versions of Turbolinks was a progress cursor, which meant there was no feedback as to whether anything was happening while the page was loading. This was sorted in the later versions by adding a progress bar at the top of the page, similar to github, which is enabled by default, meaning that the issue was solved.
Of course Turbolinks is not always ideal. Personally, I saw 2 main edge cases which you should know about before adding this feature:
document.ready: The first step is to trigger the
document.ready, however, this doesn’t work with Turbolinks. The workaround is to always use
page:load near the
Turbolinks is very much underestimated and can be used on numerous and varied projects. We are currently using it on one of our larger projects and I find that it works really well.
This library had a bad reputation in the beginning of rails 4 because it was added as default in all new rails apps, and half of the developers had no clue what is was. They thus started to get angry every time their
document.ready wasn't working.
But aside from this abrupt introduction, I believe that Turbolinks really helps grow a project - and makes it look great!