We Removed jQuery
outsideonline.com
outsideonline.com
Nope. If you like it, and you don't have performance problems for which jQuery is a significant contributing factor (which is extremely unlikely), then keep using it.
So, if your site is small and has medium to low traffic, there's not really a "good" reason.
But if you have high traffic you might want to really squeeze every saving you can
(The article says: "[...] when you consider that we have over 5 million pageviews to the article content type in any given 30 days, it translates to roughly 150GB of bandwidth saved." But that is utter BS that wouldn't pass a sniff test with a 10-year old who understands a modicum of browser caching and network caching.)
1) If it's not on your resume it needs to be. 2) If it's already on everyone's resume you must seek alternatives 3) Resumes are never finished, only abandoned
I'm starting to feel like I should expand this into a manifesto.
<sarc> Yes, let's give the clueless tech recruiters more ammunition to screen out otherwise qualified candidates after someone with a blog stumbles across your site and suddenly recruiters are doing machine learning-matching on resumes against "the manifesto" </sarc>
I think the trade-off is that you opt for a more wholistic approach or framework that is more costly to bootstrap but easier to maintain, especially as complexity increases.
The reason I don't use jQuery these days is because other libraries serve jQuery's functions a little better for me.
* If I want a more robust interface for my XHR requests, there are a ton of nice libraries out there. Superagent is a good example.
* If I need utility belt stuff, I can get more out of Lodash, Ramda, etc.
* If I want animations, there are much better ways to do that nowadays, even with just basic CSS3.
* If I need distinct DOM lookup and manipulation...well, this might not be needed at all if I'm doing an SPA (in React, etc.). That said, there are compelling alternatives that I like, such as bonzo.
And then there's just the fact that you can now do an awful lot with bare Javascript.
So my argument against jQuery is less "jQuery sucks" and more "I prefer using all these other tools that cover the same surface". jQuery is still a marvel for all the conveniences it provides, and I don't think anyone should stop using it just because the cool kid says so.
jQuery is going to select and manipulate elements, but it's not going to compensate for when the developer does moronic things like creating DOM elements a bajillion times with HTML strings in jQuery every time something changes, animating things in improper ways(like animating dimensional properties that cause extra redrawing before postrender), etc.
There's nothing wrong with using jQuery. I just find that I don't even need it and would much prefer to just use existing APIs in its place. If there's a compatibility issue, I can install a polyfill that's much smaller than jQuery ever will be.
The most recent project I took over had jQuery loading on every page. Even though jQuery was actually only used on maybe 10% of the pages. And the thing the previous developer was trying to accomplish with jQuery can be easily done in CSS.
Needless to say, that web site is now jQuery free.
There's a whole lot of complexity due to cross platform browser compatibility, working around various quirks, especially in the event handling plumbing, etc. It provides some nice conveniences, but if you're not using them, you're still paying for that big fancy layer.
Also, jQuery's APIs tend to be very polymorphic and fuzzy and interpretive, taking different numbers and types of parameters, supporting multiple overloaded interfaces, wrapping and unwrapping proxies, sniffing parameter types and shuffling them around, applying various defaults and shortcuts, bending over backwards to be "fluid", etc.
That kind of dynamic code has a cost and doesn't optimize so well, compared to the simple crisp unambiguous calls with with regularly typed parameters directly into native code that the newer standard DOM APIs tend to provide.
But the worst thing about jQuery isn't its own fault, it's the way people use it. I've seen so much jQuery code that repeats selectors and other slow searching method calls again and again because the programmer apparently thought calling into jQuery was faster than using a local or instance variable, doing the expensive computation once, then re-using the result.
Or maybe it's because using local variables doesn't match with jQuery's "fluid" style of chaining method calls. As if it was bad luck to break the chain of method calls by using a local variable and giving something a name.
And many people tend to use jQuery as a crutch to avoid learning and using JavaScript itself. (This explains all the excitement about that jQuery plugin that adds and subtracts numbers.)
https://github.com/cbrandolino/jQuery-basic-arithmetic-plugi...
Back in the day when you had to target IE-6 that made sense - the web was so broken you really needed something it jQuery to render it sane. But that time has gone now, and I can't count the number of times the jQuery solution actually used more core than raw js.
Doing this is positively harmful. Not only is it slower and creates clashing dependencies because library A wants jQuery version B, but library Y wants version jQuery Z, it forces the programmers to learn the 10'th different way of doing something (there are always at least 10 libraries that do it). It's unnecessary because there is one thing every javascript programmer should know (and it's not jQuery) - it's modern javascript and the standard library provided by a IE9+ browser. If it can be done with a few lines that then that is how you should do it - because it makes like so much easier for those who follow you.
I’d say it’s quite easy to build slow sites on any platform. I also know it’s very well achievable to build truly perfomant sites on Drupal. Also, with the sites built on top of these CMSs, performance very rarely actually becomes an issue. The number one worry with the sites is their unmaintained codebase and all the security implications that come with it.
I really like Drupal 8 and I certainly wouldn’t call it bloated. It’s extremely modular and you can enable just the things you need. What I really want, though, is that people would take better care of the sites they build on it.
1. Upgrading jQuery has been hell over the years. Literally every time something wierd breaks. Major version like the 2.0 transition meant major rewrites.
2. Most of the plugins seem to of varying quality between dire and just about usable but even the best we used died and got abandoned. I've had to fork, maintain and fix a load and then most of the contributors of those plugins don't know or care about updates or forks or pull requests or are total assholes so we're doomed to maintain them forever.
4. It is terribly slow in some circumstances. You don't know this until you find some client who is using a Citrix terminal deployment and is forced to use some tail end supported version of IE. And they are the loudest complainers.
5. It's pretty difficult to get rid of it. The tentacles are right in there. That monkey is on your back forever.
6. It's huge. Core isn't but by the time you've dragged in everything in via plugins to be productive you've got a meg of insecure god knows what crap running on your front end.
Regardless of the progress in browser tech, having your stuff run like ass, which it will in the future (I know after 10 years), because it's easy and convenient is just wrong.
I'd like to add on to your main point. Improving page loading speed is a major issue for some places. I've seen one and instead of fixing the issue (their awesome home made DAL) they did all kinds of things several orders of magnitute smaller in terms of the amount of time they took. Now maybe they had some hidden reason for the way they were doing things, idk. My point, if I have one, is to pay attention to what's causing the page to load slow.
I have zero knowledge on Drupal but is this true?
Disclaimer 2: The following method isn't something we recommend if you rely heavily on front-end contrib modules, authenticated traffic, or parts of Drupal 7 core that depend on jQuery.
Really, mostly getting rid of something is an effective optimization; 80-20 rule applies.
The mentioned 150GB bandwidth saving surely sounds good however when I contemplate about ROI somehow I still endup thinking: it’s not worth it. Or maybe I’m just too old.
People hate farrrrrr too much on jQuery. Sure, you should remove it when you can but the library size plus the fact it’s likely already cached on the browser from a common CDN makes it seem quite silly to go out of your way to remove it.
This is a missconception. The problem of multiple CDN's and various patch releases of shared libaries means the hit rate is only likely to be in the 2% region.
https://www.root777.com/appdev/does-using-google-libraries-a...
Developers tend to focus on their use-case too much.
> Before our jQuery removal refactoring, the bundle file on our most popular content type, article.min.js, was 139kb minified (gzipped 47kb). After our refactor, our jQuery-free code comes in at 50kb (gzipped 15kb).
So it sounds like they bundled jquery into article.min.js. But then they go on to write:
> This might seem trivial, but when you consider that we have over 5 million pageviews to the article content type in any given 30 days, it translates to roughly 150GB of bandwidth saved.
This then indicates that no request to their most popular javascript will be cached by clients, which seems odd. I don't think people typically mean "unique visitors" when they say "pageviews", or?
I clicked on ~5 pages on their site and my browser downloaded about 10MB. Their JQuery optimization saved them 30kB. From a bandwidth perspective, it doesn't seem so significant.
Edit: Actually I almost get upset when I browse their site. My laptop screen is 1920x1080, and their content doesn't really fit on the screen. I'm thinking about for example the "Dispatches" section on the / page. I can't even see the complete frigging boxes without scrolling. The font size of the header is crazy 150px and then the boxes underneath. Wtf. Now, this blog article reminds me of those from Netflix about how they improved some "blablabla-engine" and then they can't even be bothered to do a somewhat user friendly site.
Or does each page have a different bundle so that the browser cannot do any useful caching?
The other major benefit is that it's (fairly) easy to swap out either the frontend or backend. If we need to migrate to another CMS, we don't have to change anything on the frontend as long as the new API confirms with the old. And vice versa for migrating to another frontend. Also if you need to create an app or any other application you already have an API.
I wouldn't necessarily use this same architecture for smaller sites, but for enterprise it's a pretty good option.
That’s the exact opposite of a technical reason. Actually sound like following the hype.
Their 'conditions for removal' are half made up of reasons they want to remove jQuery. Makes no sense.
It's almost a static site without any interactive functions. 46.9KB unzip JS still seem too much.
On another side, they have more than 30KB preloaded articles data on every page. That could be a 2nd Ajax call or a better data structure. CSS is another place I think that can be optimized.
Obviously, the Drupal settings and few JS functions are added twice and debug mode for JS bundle is enabled I bet.