Ask HN: Is jQuery still a thing?
With so many "new" js frameworks (like React, Vue.js, Mithril,..) and js-like languages (Elm, Dart, TypeScript,..) is classic jQuery still taken as something good and recommended to use for the front-end? Or should it by replaced by something else? Maintainability and minimum of errors are more relevant for me than raw speed or "hype".
89 comments
[ 4.0 ms ] story [ 159 ms ] threadhttps://nerdydata.com/search?query=jquery
I get the feeling more and more that developers are embarrassed about using it, similar to how some devs are embarrassed about using PHP, yet it's still a workhorse.
The fact that it still works is important. As long as I've got clients asking for IE 8 support, jQuery's going to be in my toolbox. And probably even after.
If you are starting a new project on it, you should indeed feel silly.
I picked floating point math as a problem because JScript would give you an incorrect answer.
There are more than 2 languages available for backend programming. Some even get both templating and IO right.
Laravel collections alone make it almost a functional language when using it w/ laravel.
Also honestly, I don't think I should look now. The PHP applications I see around are still the ones getting serious vulnerabilities found every week, the same ones that other communities found ways to pack the solutions into tools and conventions that are easier to use than not to. I also don't see anybody claiming PHP has any new template system to replace the dated original one.
I've seen some progress on the language, but not nearly enough to make it compelling. I have plenty of stuff already on my ToTry list, PHP would have to say something better than "I'm not a complete mess anymore" to enter it.
Because the language is a bit archaic (has maintainability problems for large codebases, has the "too little power" problem for small codebases); as far as I have looked, the ecosystem still does not include a good templating system (although it does include most of the tools available on other web ecosystems); and the community is still heavy on applications with the same kinds of security bugs they always had, and many, many "X-only" developers.
And, anyway, fixing those outstanding problems can only make it an ordinary language. And there's no reason to look at any language that the best claim is "it's not worse than any other random language".
Pick the right technology to solve the problem you're trying to solve.
Some inexperienced devs just try and cram every single technology they've ever heard of into a simple project when it's not needed. You're not at Facebook's scale just yet where many of these abstractions are anything other than an extra complication and a waste of time and future liability.
Your average simple website for a law firm, bike repair shop, or a pizza delivery place doesn't need 93 different libraries/frameworks/technologies/build systems/etc to show/hide a couple products or submit a form or two. You can go pretty far with just jQuery in many cases.
It gets a little more complicated as you go from simple site to more complex site to app to more complex app, but I see too many developers trying to be trendy and over engineering simple problems and wasting a lot of time and money.
jQuery had it's time. Now you just use "vanilla" JS and it is enough. No external dependencies for your landing-page / non-web-app site.
Yes, "you might not need jQuery". But, the first time you have to log real hours fixing a cross-browser bug that the jQuery team already took care of, I'm fucking firing you. Choose wisely.
"If you make a mistake try to cover it up rather than be honest about it, because your arse is on the line".
2. Profit
> If you need to support older browsers like Internet Explorer 6-8, Opera 12.1x or Safari 5.1+, use jQuery 1.12.
But it's not about whether there is something better, it's whether it's still needed or not.
For UI elements that have a lot of internal state, React can remove a ton of complexity. However, the delay between initial page render and the React component rendering itself can sometimes be distracting when those elements are key parts of the UI. This is a solved problem if you're using Node on the server, obviously, but if you're rendering pages with other server-side technology it is a drawback to React. jQuery does not have these issues as it just attaches itself to the server-rendered markup.
The frameworks you mentioned are not exactly in the same "niche" as jQuery, which encapsulates a friendly way to manipulate DOM, make ajax requests, etc.
However, if maintainability is your focus, write in plain js as much as possible. Frameworks come and go. Code written in ES5 will still work in 5 years from now, while jQuery code may get at least partially deprecated.
And if you don't work for a company that is in the JavaScript-framework-of-the-month mode, you should know JQuery is still king.
That being said, I agree with your last statement. For better or worse, jQuery still seems to be king.
This just isn't true. OP mentioned React, Vue.js, and Mithril. None of these use jQuery as a dependency. Neither does Angular, Backbone, or Ember.js.
That being said, I don't think knowing jQuery is very valuable for JS developers anymore. Browser standards have come a long way and frameworks are handling your DOM writes for you, so that major use case for jQuery is gone in any website that requires substantial scripting.
But I think that's really only so the Ember jQuery wrapper will work properly. So you're still right.
[0] http://openui5.org/
I'd also argue that this as a current generation framework. I only did a brief skim but the patterns remind me of a Knockout or Enyo codebase with data binding between components doing explicit dom manipulation. The contributors tab shows a 2014 start but I'd have guessed a 2010-2011 start from looking at the code.
I'm an SAP and UI5 developer.
A better way to state that:
"Is jQuery omnipresent now? Yes.
Will jQuery earn you as much money as on the peak of first gen webapps craze? No, totally no"
I myself was earning CAD $90k just in plain salary at the time when jQuery craze was on its peak and when "a dedicated front-end developer" meant a jQuery developer
Honestly saying, I had no realisation how shitty my code was back then, and now I feel ridiculous when I realise how much a bad dev can earn as long as he does something considered "trendy"
For adding simple functionality to a web page, I would probably ever ONLY use jQuery. (Assuming plain js was going to be a hassle.)
FWIW I haven't used much jQuery for about the last 3 years, and all I do is web apps all day every day. The day I discovered Knockout (as the gateway drug) was the day life got exponentially better.
2.3 million downloads in the last month and 4883 dependencies... what do you think?
If you're writing more than a couple hundred lines of javascript, the jQuery model of putting your application state in the DOM is inferior to pretty much any other application model. There's a reason everybody went to Backbone and then to the component libraries. Separating your model and rendering concerns and delegating the latter to your framework roughly halves the amount of code you need to write.
I'm an Ember developer myself, and I love it, but there's no way in hell I'd use it for a small website. For that matter, I wouldn't use React or Angular 1.x either (I haven't had to do any project in Angular 2.x yet, so I don't really have an informed opinion yet).
So, that out of the way, next up is jQuery, which I think is still a perfect fit for smaller projects. The fact that you can just use it, without having to worry about any real initial prep-work, or having to compile anything, is almost kind of magical in this day and age.
"webapps" typically use a concoction of 100+ js frameworks/plugins, including one of angular/react/ember/backbone (or in some really hotness of the month type places - more than one of those).
it's of useful to know jquery, just to keep things simple when you can.
The way I build web apps is to use intercooler.js (which is built on top of jQuery) for my AJAX and then jQuery, or jQuery-based plugins, for UI needs.
Works great. Yes, the jQuery API has some aspects that haven't aged all that well, but it's a pretty well thought out and through library that provides great tools that should have been baked into all browser environments since the start, and that has a rich ecosystem around it to boot.
The jQuery haters are usually folks who tried to write an SPA with it, which they say, correctly, is a terrible idea. But then, building an SPA is usually a terrible idea as well.
Would you care to elaborate on this? I'm interested in why.
Long-suffering HN readers can skip all of this (sorry guys) but I expand on this in the following blog posts:
http://intercoolerjs.org/2016/01/18/rescuing-rest.html
http://intercoolerjs.org/2016/02/17/api-churn-vs-security.ht...
http://intercoolerjs.org/2016/05/08/hatoeas-is-for-humans.ht...
For my use cases, discoverability and ad hoc queries just don't apply.
The query issue just depends on how complex your data consumption needs are. The closer they get to levels requiring SQL-levels of expressivity, the more you will need to either churn your API or expose expressivity (and security risk) on the browser side.
In the old days, the way we dealt with changing the UI in another location was by simply replacing the whole page. This actually works pretty well, except for those FOUCs, and we are heading back that way, but now people are starting to do DOM diffs to avoid the blinky-blink. intercooler has a few options for solving it as well (either expanding your replacement target or using dependencies.) I imagine eventually I'll end up adding DOM-merging as an option as well.
Anyway, it's a long conversation.
This will be nice. I was playing with some of the examples on the site and noticed a number of them tended to "jump" a bit when the response was returned.
1. There are some edge cases where it is still useful and it would be way more painful to reimplement it in vanilla js (though maybe still possible). But in these edge cases why bother when:
2. In any largish project invariably _something_ will require jquery. Think Bootstrap or some widget library the boss/users absolutely want or something some "UI" person built themselves.