Chapter 21 Turbolinks

Turbolinks is a JavaScript library that, when enabled, attaches a click handler to all links of an HTML page. When a link is clicked, Turbolinks will execute an Ajax request, and replace the contents of the current page with the response’s <body> tag.

When Turbolinks is activated, it uses the HTML5 History API to dynamically change the address of the current page, enabling users to bookmark a specific page and use the back button as they normally would.

The biggest advantage of Turbolinks is that it enables the user’s browser to only fetch the required stylesheets, JavaScripts, and even images once to render the page. Turbolinks effectively makes your site appear faster and more responsive.

Turbolinks is automatically included ...

Get The Rails 5 Way, Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.