Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell for sure that turbo links is working?

I am experimenting with configuring turbo links correctly. Is there any way (by tracing, javascript console, examining the html, or anything) to see proof that turbo links is working? Simply looking for "faster" or "no flashing" is too subjective.

like image 843
pitosalas Avatar asked Apr 04 '17 02:04

pitosalas


People also ask

How can I tell if Turbolinks is working?

on('turbolinks:load', function (){ alert("turbolinks on load event works") }); If you reload a page where this JS is running, and the page shows you an alert, turbolinks is working.

How does a turbo link work?

Turbolinks works by automatically fetching your page, swapping its DOM's body, and mixing it with the head . This allows the library to understand what has changed on the page without having to infer a full load.

How do I enable Turbolinks?

6.1 How Turbolinks Works The only thing you have to do to enable Turbolinks is have it in your Gemfile, and put //= require turbolinks in your JavaScript manifest, which is usually app/assets/javascripts/application.

What does Turbolinks do with your browser's history?

Turbolinks saves a copy of the current page to its cache just before rendering a new page. Note that Turbolinks copies the page using cloneNode(true) , which means any attached event listeners and associated data are discarded.


1 Answers

Try this in the application.js file (or any other js/coffee file that's getting run):

$(document).on('turbolinks:load', function (){ alert("turbolinks on load event works") });

If you reload a page where this JS is running, and the page shows you an alert, turbolinks is working.

like image 185
ellitt Avatar answered Nov 10 '22 16:11

ellitt