3 ms·
The speed improvement from turbolinks can be quite significant. I have an application that was purpose built for pjax and later converted to turbolinks. Page lo
by k1w1 13y ago
The speed improvement from turbolinks can be quite significant. I have an application that was purpose built for pjax and later converted to turbolinks. Page loads are noticeably faster than without turbolinks, and are on the same order as a fat-client application.
The beautiful part is that while writing most code in pure Rails you don't need to think about turbolinks at all - it just comes for free.
BTW, turbolinks is a bit improvement over pjax. It is much simpler (since the whole page is loaded), discouraging some of the complexity that you might be tempted to introduce by pjaxing different parts of the page.
Converting an existing app to turbolinks will take some work, especially with how JS is handled. The key is to run your JS on the turbolinks "page:change" callback and then call the same callback on the initial page load:
$ ->
# Simulate turbolinks page change on document ready.
$(document).trigger "page:change"
- cheald 13y agoDoes it still break horribly and double-request everything if you have things like <link rel="canonical"> in your website?
- chc 13y agoI don't know when it was doing that, but the current version of Turbolinks only seems to affect the Asset Pipeline. It doesn't do anything to random link tags on your page. I specifically checked a page with rel="canonical" and Turbolinks only made one request.
- cheald 13y agoLast I looked at it, Turbolinks parsed the <head> section of the incoming request to see if any assets (which was basically...count the script/link nodes) changed. If they did, it went ahead and redirected to the requested URL, since it couldn't be sure that assets hadn't changed. This meant that anything page-specific in your <head> caused Turbolinks to double the work your app had do to, and provided no positive benefit at all. I'll check and see how it's behaving now. Edit: Looks like concerned assets are now tagged with a data attribute. Glad that's in there now.