Skip to content

Turbo-charging your WordPress site with Turbolinks

At Storm, we use a variety of tools, frameworks and programming languages – we’re committed to being polyglot programmers and to using the right tool for the job!  This gives us a broad view on the world and lets us see what different groups of people are up to.  We’ve been watching the development of Rails 4.0 with interest and one feature in particular has caught our eye: Turbolinks.

Turbolinks promises to speed up page load times by performing some JavaScript wizardry (in modern browsers).  It intercepts clicks on links and makes an AJAX request for the content, instead of letting the browser handle the request.  When the response is returned, only the <body> contents are replaced.  This means the browser doesn’t try to re-download or parse assets like CSS and JavaScript.  Some magic makes sure that the page is properly reloaded if required assets are missing though.

We like fast web pages so we thought it’d be nice if we could get it working outside of Rails and inside of WordPress.  After a bit of hacking around we have a beta version that you can have a play with.

Introducing, WP Turbolinks, a drop-in plugin to enable Turbolinks on your WordPress site.

Currently the code is only available on GitHub and requires manual installation.  We will be putting it on the WordPress plugin directory once we have done some more testing and received feedback.  Please do install it and have a play with it, however, there are a few caveats.

Caveats

  • Turbolinks requires document ready handlers to be idempotent.  This is far from standard in JavaScript libraries and may require you to do some significant work to make your JS work with Turbolinks.
  • Many plugins also add JavaScript to your page and they are probably not idempotent – so you may run into problems here.
  • The Turbolinks pattern means that there is no loading indication in the browser, unless your site/server combination guarantees pretty fast page responses anyway then you are likely to find that a lot of users are very confused because ‘nothing is happening’.
  • This is very much a beta, we have not put it through lots of testing and we do not know if there are any unforeseen consequences of using it.  Use it at your own risk.

That said, Turbolinks could offer a significant speed up to your site!  Try it out.  Test it.  Let us know how you get on!