Rails without jQuery : a new journey has started
Posted March 8, 2021 - tagged ruby-on-rails ‐ 2 min read
I have never worked *without* jquery. I have never followed the 'no-jquery' hype. But let's face it, even the giants are removing jQuery from their stack. Rails 6 now works without jQuery. Bootstrap 5 now works without jQuery. So as a developer, when I see this kind of trend, I wonder if it's not time to reconsider.
It's not about the size
jQuery is not that big. A few dozen of KB are nothing compared to the high-definition background video the designer requires you to add on the landing page.
However I understand the dev's frustration. Browsers are able to handle what jQuery does. Thus, using a 3rd party lib instead of a standard, native solution seems a "code smell" at first glance.
It's about habit
The jquery API is very intuitive. And shared across the globe. Around 2014, as far as I can remember, it was used by about 90% of the websites (I can't remember the source, sorry).
The plugin ecosystem was extremely wide.
At that point, I really wonder why jQuery was not seen as a web standard, and directly integrated into browsers. W3C could have decided it years ago.
Anyway, now, it's too late. Almost everything can be another way, just by following standard web API.
Now web browser comes with an API that is :
- a lot more verbose
- a lot less intuitive
Let's take an example :
- You can code the jQuery version "right now", with limited jQuery knowledge.
The ecosystem has evolved. I now often see tiny libraries that are shipped with ES6 only in mind. I already talked about Rails and Bootstrap, but even my favorite accessibility lib, originally built with jQuery, has now a vanillaJS alternative.
Maybe it's time for Rails app to try to be entirely built without jQuery. I know, there are many apps (and devs) who already jumped into this "danger zone" a long time ago.
For the private admin backend, I still embed jQuery, where I feel that the need for performance and standardisation is not as important.