195 points · by gslin · 3y ago · 111 comments
But the jQuery UI widgets are battle hardened and easier to deploy, case in point , date pickers, calendaries and well, slideshows.
And you can kind of replicate some of reacts behaviour regarding state management.
If all you need to do is keep state on a handful of elements, there is no need to develop in react.
Infact, just like the jquery heydays, react is often overused, for the most simply web forms, menus, footers.
And, no need for router and other state management tools.
Might be a bit unpopular, but when its all said and done, its compiled to js either way, I kinda like jquery or vanilla js for the front end and node/express for the back end.
The amount of react devs which struggle with css and vanilla js appears to be higher than during the jquery days.
But I never really liked jQuery UI, either as a user or developer. As a user, the whole "desktop semantics in your browser" is one of those things that was worth trying 15 years ago, but it mostly never really worked all that well, and pretty much everyone has dropped it.
As a developer I feel jQuery UI is too complex for what it does, partly because of the above.
At any rate, jQuery and jQuery UI are two entirely different projects.
jQuery UI is "in a maintenance state" and "older long-standing bugs may not get fixed" I'm afraid
https://blog.jqueryui.com/2022/07/jquery-ui-1-13-2-released/
You need to have a reason to pay the price of React. Otherwise you're just being a sheep.
I say this using React and Material UI in a present project, from my perspective development for what is a pretty simple form UI is massively slowed down by using them.
Could have knocked out the whole site on my own in 1/2 the time using the 'old' stuff.
But now we've got a lovely loading spinner while it downloads everything it needs piecemeal and a bunch of basic browser functionality is broken, we've got 10x the amount of code, have to deal with a whole extra API layer and it's a nightmare to debug sitting there watching network calls instead of being able to step through the code in a proper debugger, brilliant stuff.
Completely worth it for that one datepicker we have.
<input type="date"> is too rough I'm guessing? I'm not exactly sure where it falls short personally.
You ask yourself, "do I feel like writing a calendar selector widget today?" Trade some vanity and JavaScript puritanism and the question becomes "what color should I style it?"
While we're at it - Bootstrap (and similar css frameworks) are still much nicer to use than native CSS, even with modern CSS3 and flexbox...
It's almost like the designers for these native-API's look at what the community uses, and then decide to do something similar, but different just because.
This is an understandable interpretation, but I think the real explanation is more nuanced (and more favorable). Web APIs do tend to be inspired by existing use cases like you say, and that’s a good thing. But from there they tend to be low level—in the sense that they’re designed for library authors, at least as much as they’re designed for end users—either as an explicit goal or as an implied general principle.
Taking inspiration from real usage is unambiguously great. Lower level APIs might feel more painful for end users (and can lead to dependency-itis which is a constant target of scorn here and all over). But the benefit is that these less friendly APIs are also well designed to be used in a wider variety of ways, without much influence on their own higher level interfaces.
More concretely, the DOM as designed allows jQuery and React to coexist and thrive for their own target audiences, in a way that would probably be much less likely if the DOM had been designed more like either one of them. This is similarly true for APIs like Intl (which I’ve used directly, and it’s fine… but it’s definitely better as a library target than for every day usage).
In jQuery, you can select almost anything with just the constructor. It's simple... and clearly better.
> in the sense that they’re designed for library authors
Libraries shouldn't be necessary to write basic DOM manipulation code. Modern ECMAScript has been promised to do away with all the "hack" libraries like jQuery... and articles like "You might not need jQuery" sprang up in popularity based on new ECMAScript features.
But, modern ECMAScript is objectively harder to use, more clunky and verbose. Even the naming of functions is absurd... "querySelector()" instead of just "select()" or "get()"...
The problem with the javascript community is nobody actually knows javascript. No, people know whatever framework/lib they work with, which is not the same thing. It's that way because javascript... sucks to use.
The main reason to still use it imo it is simply that a lot of devs are familiar with the API and they have really good docs.
While I prefer vanilla JS for JS-light projects, I'm also aware of some cross-browser weirdness and combability issues you might run into with a vanilla JS project. The nice thing JQuery is that you know it will work as expected on the all browsers it supports so you don't need to worry about cross-browser testing your code. It also makes certain things easier to do like basic JS animations.
The main reason care about the latest releases is that they patch security issues from time to time.
That was the main reason that jQuery got popular if I remember correctly (though I have always been an 85% backend developer). I was under the impression that that isn't really an issue these days, but everyone is building overly complex monstrosities with React or whatever else is flavor of the month.
The various browsers have gotten together and work awfully hard to fix outstanding quirks. You'll still encounter cross-browser oddities here and there, but it's generally more in the order of, "X browser hasn't added this method yet"
The other raison d'être is the API, which is simply much better than even the latest DOM API. It's actually pretty remarkable that jQuery API feels spot on even after 16 years.
[0] https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/U...
Apparently you need to use some special object type. Why doesn't the universal key/value type work for passing a key/values? Who knows – maybe there's a good reason, maybe not. I do know that sending [object Object] is literally never what anyone could possibly want and that almost any other design choice would be less idiotic.
So I just use xmlHttpRequest or jQuery.ajax(). xmlHttpRequest is kind of awkward, but it's straight-forward and you don't get nonsense like this.
I also don't care much for promises, and fetch is pretty promise-heavy.
https://developer.mozilla.org/en-US/docs/Web/API/Web_Animati...
I am not a web developer I learnt HTML in the 90's (When Frames and Tables were the way to write web pages). I have not kept up to date with current State of the art in web development. I know enough about JavaScript to read source code and kind of understand what it is doing but don't know anything about best practices or the 'proper' way to write it.
I needed to throw together a simple webform to submit a date as one of the inputs. I was having problems getting it to work consistently across different browsers.
One of the issues I was having was I needed the date to be in the Australian date format (DD/MM/YYYY) but one browser (I can't remember which Edge maybe??) kept insisting on using US style dates MM/DD/YYYY it caused me a lot of frustration maybe I just didn't know the correct phrase to search google for but I could not work out how to make the browsers built in calendar picker force the date to be in a specific format.
So I just used the JQuery calendar picker took me two seconds and problem solved.
And it's not only WP. Plenty of big companies use it too. Amazon (the store) used it until a couple of months ago IIRC.
If you don't need a super sophisticated frontend, jQuery is still one of the best tools around.
People argue vanilla JS can do everything jQuery does, which is true for jQuery and any JS framework really, but they're really missing the point. With jQuery you can do express complex logic in a single line that would take many more lines in vanilla JS.
Since they don't know any better, they equate MOST POPULAR with BEST.
Sometimes all you need is a wheelbarrow, you don't need a tractor.
It’s just that it’s a lot better and easier. The fact that we haven’t standardized on jQuery’s API is one of the greatest missed opportunities in the field.
But I'm still using some dependencies that need jquery.
I honestly expect I'll never be able to get rid of it.
If they're independently managing their own parts of the DOM, it can work (though still a dev headache imo).
If its a "react app", ie react is managing the entire dom, having two representations of the dom is a v bad idea in that one can make changes that the other is unaware of. Or visa versa.
Every React example I've seen is a horrific-looking mixture of JavaScript, XML, and HTML all muddled together into a nasty-looking component system.
When I was learning front-end development it was an absolute cardinal sin to mix markup, JavaScript, and styling together. Now that seems like the standard practice and I still can't look past it.
I agree with your opinion of React/JSX, but the single file components of Vue and Svelte are an absolute joy to work with.
EDIT Spelling
As an infrastructure engineer with zero interest in Frontend trends, jQuery simply gets the job done.
alpine.js could be an alternative to jQuery.
wonder if jQuery is still used for new projects these days.
I prefer lightweight tools that solve big problems while still staying small/simple. Alpine.js really hits that balance for me. The fact I'm able to drop it in without a single Node.js/etc build tooling is astounding (esbuild, rome, etc). I really prefer how it stays true to vanilla JS/general web development while also bringing modern attribute-driven reactivity to the table.
I guess I should specify, not available as easy as jQuery. Technically anything that jQuery does can, obviously, be done natively, but I remember there were some things that were much much much easier to do in jQuery than natively. Some of those easy patterns have been adopted into native, but surely not everything.
Array.from(document.querySelectorAll('.foo')).forEach(el => el.style.display = 'none');
Being able to select something, then chain operations on those nodes is really where jQuery shines, IMO. All of the non-DOM stuff (e.g., AJAX) is fine with vanilla JS these days. document.querySelectorAll('.age').forEach(el => el.style.display = 'none')
But I didn't have to do anything like that in years. With reactive frameworks you just bind visibility and styles to variables, refs or some central state.I fail to see the superiority of that approach after more than a decade.
To me, the success of React and the likes has more to do with team dynamics, hiring, etc.
some-selector .foo {
display: none;
}I don't know why querySelectorAll() doesn't just return an array.
It is easy as hell. What's there to not like? I don't care to be called names or being old fashioned.
I also don't care about "right" tooling for frontend. As far as it works, it is robust and it is going to be around for many years, I am fine with it.
The foundation lists jQuery under its Impact Projects which are described as:
> Impact projects are on a sustaining cycle of development, maintenance, and long-term support. These projects are used commonly in enterprise production environments and have large, well-established project communities.
> ...
> They receive ongoing financial and marketing support from the Foundation, and are expected to cross-promote the foundation along with their activities.
This seems to me like they expect to continue to support jQuery for the foreseeable future.
The CSS selector bit was always the strongest portion to me. Getting that into your project allows you to get more work and involvement in the system from your 'just a frontend person' people, and reluctant backend people working on the UI.
Add to this the ability to apply CSS selectors to your ancestors, which has been lacking from DOM for far, far too long.
But the last leg of that stool is the list comprehension semantics. Being able to implement "select all" or "clear all checkboxes" in one line of code. The only problem with this functionality is that it fails silently on a bad or out-of-date selector, and I think that was a mistake, but one that is hard to fix in retrospect without creating another library with different defaults. I think by default that such a call should fail, with an override for that 1 in 20 case where you just don't care.
I'd also like to see either fewer frameworks or more frameworks that have thin veneers over common libraries, like jQuery. People underestimate the psychological safety people get from feeling that they could leave a job or ecosystem whenever they want. We behave as if stuckness leads to complacency, but your best coworkers see complacency as a warning, and will choose half-considered actions (like jumping ship) as a viable alternative to the status quo. People who get unstuck can become your enemy instead of just an ex-user as well, feeling they need to 'rescue' others from your dirty clutches.
The following is more stream of consciousness than something I've thought about, so someone who has thought about it longer can probably clever out a good answer. In later versions it's tried harder not to get itself into reflow loops, but since I'm not an active user anymore, I don't know if that's so much a standalone feature as it is fixing bugs in the abstraction. There's probably other ways to fix such problems too, something more like zip() semantics, where you take a selector, run all of the get() operations, look at the answers, and only then mutate the list. Perhaps there's a two argument API in there, or maybe a fluent interface would flow better.
document.querySelectorAll('[name^="starts-with-this"]')
or "containing" selectors: document.querySelectorAll('[name*="contains-this"]')Times like that make me highly qustion my career choices; especially when their pay scale is similar.
So my verdict: "you shouldn't use jQuery"
> Return undefined for whitespace-only CSS variable values
I've gotten in the bad habit using of CSS vars for dynamic text, this will shoot me in the foot some day.
Can you elaborate on this trick?
I update the value of `--sale-text` to change all elements with that given classname to "25% off!" instead (for ex).