---
title: "Rails 5.1 dropped jQuery dependency in default stack"
description:
  "jQuery dropped as a dependency from Rails 5.1 onwards and replaced by a
  vanilla rails-ujs driver for the unobtrusive JavaScript helpers"
canonical_url: "https://www.bigbinary.com/blog/rails-5-1-has-dropped-dependency-on-jquery-from-the-default-stack"
markdown_url: "https://www.bigbinary.com/blog/rails-5-1-has-dropped-dependency-on-jquery-from-the-default-stack.md"
---

# Rails 5.1 dropped jQuery dependency in default stack

jQuery dropped as a dependency from Rails 5.1 onwards and replaced by a vanilla
rails-ujs driver for the unobtrusive JavaScript helpers

- Author: Neeraj Singh
- Published: June 20, 2017
- Categories: Rails 5.1, Rails

Rails has been dependent on jQuery for providing the unobtrusive JavaScript
helpers such as
[data-remote, data-url and the Ajax interactions](http://guides.rubyonrails.org/working_with_javascript_in_rails.html#unobtrusive-javascript).
Every Rails application before Rails 5.1 would have the `jquery-rails` gem
included by default.

The `jquery-rails` gem contains the jquery-ujs driver which provides all the
nice unobtrusive features.

But now JavaScript has progressed well such that we can write the unobtrusive
driver which Rails needs using just plain vanilla JavaScript.

That's what has happened for the 5.1 release. The `jquery-ujs` driver has been
rewritten using just plain JavaScript as part of a GSoC project by
[Dangyui Liu](https://github.com/liudangyi).

Now that the unobtrusive JavaScript driver does not depend on jQuery, new Rails
applications also need not depend on jQuery.

So, Rails 5.1 has [dropped jQuery](https://github.com/rails/rails/issues/25208)
as a
[dependency from the default stack](https://github.com/rails/rails/pull/27113).

The current [jquery-based](https://github.com/rails/jquery-rails) approach would
still be available. It's just that it's not part of the default stack. You will
need to manually add the `jquery-rails` gem to newly created 5.1 application and
[update the application.js](https://github.com/rails/jquery-ujs#installation-using-the-jquery-rails-gem)
to include the `jquery-ujs` driver.

It's worth noting that `rails-ujs` only supports IE 11+. Visit the
[Desktop Browser Support](https://basecamp.com/help/3/guides/account/browsers#desktop-browser-support)
section of Basecamp to see the full list of all the supported browsers.

#### Browsers support without jQuery

We saw some discussion about which all browsers are supported without jQuery. We
decided to test it ourselves on a plain vanilla CRUD Rails app. We tested
"adding", "editing" and "deleting" of a resource.

**We found that all three operations (adding, editing and deleting) to be
working in following cases.**

- Win 7 - IE 9
- Win 7 - IE 10
- Win 7 - IE 11
- Win 8 - IE 10
- Win 8.1 - IE 11
- Win 10 - IE 14 Edge
- Win 10 - IE 15 Edge
- Win 10 - Firefox 53
- Win 10 - Chrome 58
- Win 10 - Safari 5.1
- Mac Sierra - Safari 10.1
- Mac Sierra - Firefox 53
- Mac Sierra - Chrome 58

#### API change for the event handlers

`rails-ujs` driver has changed the signature of the event handler functions to
just pass one `event` object instead of `event`, `data`, `status` and `xhr` as
in the case of `jquery-ujs` driver.

Check the
[documentation for the rails-ujs event handlers](http://edgeguides.rubyonrails.org/working_with_javascript_in_rails.html#rails-ujs-event-handlers)
for more details.

## Links

- [Human page](https://www.bigbinary.com/blog/rails-5-1-has-dropped-dependency-on-jquery-from-the-default-stack)
