Why you should use TurboLinks instead of Intercooler.js or… How to Use TurboLinks without Ruby on Rails

This blog post is brought to you by the developer of BitBudget. BitBudget is an automated budgeting app for Android and iOS which syncs with your bank account and helps you avoid overspending. If you’d like to quit living paycheck-to-paycheck and get a better handle on your finances, download it today! https://bitbudget.io

Interesting title eh? Just had a few thoughts on TurboLinks vs. Intercooler.js that I wanted to jot down here on the blog in case anyone else out there on the internet needs help making some similar choices as the ones I’ve been mulling over the past couple weeks…

So you want to build a single page application the simple way using something like TurboLinks or Intercooler.js, right? If you’re using Ruby on Rails the choice is simple, just use TurboLinks. However, if you’re like me and you aren’t using Rails and are using something else like Python & Flask the answer is a little trickier. I mean, can you even use TurboLinks if you aren’t using Rails? Well yes! Yes you can use TurboLinks without rails. In fact, it’s quite simple. All you need to do is drop a little <script> tag in your <head> pointing to a CDN hosting the transpiled/compiled version of TurboLinks and you are well on your way!

  <script src="https://cdnjs.cloudflare.com/ajax/libs/turbolinks/5.2.0/turbolinks.js"> 

To learn more about actually using TurboLinks, make sure to checkout TurboLink’s Official README on Github, and also take a look at my very basic TurboLinks demo as well.

Okay, so on to the last point– Why you should use TurboLinks over Intercooler.js. When I was first taking a look into both of these options I actually selected Intercooler.js over TurboLinks as I thought that Intercooler.js was less tied to Rails and was more of a general purpose tool compatible with whatever language/framework you happen to be using. However, I soon ran into a huge problem. After adding Intercooler.js into my project all of the JavaScript I had written on my secondary pages broke! This was pretty demoralizing and I almost gave up on the idea of using a JS library to transform my web app in to a single page application, however I decided to give TurboLinks a second look. And to my delight, I quickly found that TurboLinks handles loading JavaScript from secondary pages with ease right out of the box by default! Had I gone with TurboLinks initially instead of playing around with Intercooler.js first, my webapp would probably already be a single page application.

So in conclusion, TurboLinks is the bomb.com and you need it in your life!

 

topherPedersen