If you are maintaining an older app, you might still see jquery-ujs . But for all modern practices, we focus on rails-ujs .
You can subscribe to UJS events to show spinners or error messages:
You can add custom behavior by tapping into the UJS lifecycle: rails ujs
If you have ever built a Ruby on Rails application, you have interacted with rails-ujs —even if you didn't realize it. That subtle flash message after deleting a record, the remote form submission that doesn't refresh the page, or the confirmation dialog before destroying a resource all depend on this humble yet powerful library.
Since Rails 7, Hotwire has become the default frontend stack, with replacing many UJS behaviors. Here is a quick comparison: If you are maintaining an older app, you
The term "unobtrusive" is key. Instead of mixing JavaScript code directly into your HTML (e.g., onclick="submitForm()" ), Rails UJS uses a progressive enhancement approach. It binds event listeners to specific data- attributes, keeping your markup clean and your behavior separate.
: Allowing links to perform DELETE , PATCH , or PUT requests (which standard HTML links cannot do) via data-method . How It Works Under the Hood That subtle flash message after deleting a record,
In that case, you will likely use Turbo Drive, Turbo Frames, and Stimulus. However, many developers still reach for data-remote in Rails 7 because it is familiar and just works.
Prevent double-submission of forms:
So why should you use Rails UJS in your Rails applications? Here are just a few benefits: