Do you remember discovering how easy it was to reuse a partial from
js.erb template and the
remote: true option? Or
using the same technique to AJAX-ify a search with just a line or two
of JS? When it happened for me, I thought to myself “this is
wonderful” and immediately fell even more in love with Rails.
What’s going on here…?
Today, JS frameworks dominate the conversation, and that’s not surprising. For one thing, they are exciting and new. It wasn’t until recently that browsers became powerful enough to support full client-side MVC, and these capabilities are still evolving and being explored. SJR on the other hand is just a simple and boring (in a good way) solution that’s been around for years, first appearing in conjunction with RJS and more recently with UJS patterns. DHH described it in detail way back in 2013.
In addition to this, projects such as React and Angular are backed by Facebook and Google, huge companies with many developers and tons of resources to develop and popularize their solutions. What developer wouldn’t be curious and confident about using the same framework in his/her own app that Facebook and Google use in production? Rails, while hugely popular in its own right, does not have the same kind of reach that these companies do.
Lastly, it shouldn’t be shocking to us that SJR gets a lot less air time than other solutions because, whereas client-side JS frameworks are back-end agnostic, SJR (as we know it) is only part of the Rails ecosystem. This means that those JS frameworks have a much wider audience of developers who write and talk about them companred to the smaller audience of Rails developers using SJR.
The truth is, there are a lot of people using and writing about SJR, even in an age ruled by the client-side JS framework. Here are just a few:
- “Diving Into jQuery UJS”
Let me assure you that there are many out there who love SJR as much as you do, myself included. Not only do we think SJR is a legitimate technique for adding JS interaction to a web app, but we also believe that there are many use cases for which its even more preferable than a full-blown client-side MVC framework.
So have no more doubts… use SJR with confidence!