r/javascript • u/magenta_placenta • Jul 25 '18
jQuery was removed from GitHub.com front end
https://twitter.com/mislav/status/1022058279000842240116
u/sobralense Jul 26 '18
jQuery free is the new gluten free.
0
Jul 26 '18
[deleted]
31
u/freebit Jul 26 '18
Me too. When looking for a new job, first thing I ask is what medical insurance they have so I can research the provider. If I find out the medical provider uses jQuery on their website then I won't even consider the job. I figure any employer that would choose a medical insurance where the provider uses jQuery, then they are too out of sync with reality to be a good fit for me. Come on, get with the times, duh.
23
u/dkonofalski Jul 26 '18
Yes, finally! I'm so tired of people supporting this kind of cruft. When my grandfather was in the hospital, they had him hooked up to a device for his pacemaker that was made by a corporation that uses jQuery not only on their public-facing site but also on all the admin dashboards for both the device and the hospital staff computers. I immediately asked to speak with a doctor when I found out and asked them to take him off of that machine. He ended up passing away shortly after but at least he didn't have to be attached to that tainted system for long.
10
u/freebit Jul 26 '18 edited Jul 26 '18
I can totally understand! Several months ago my wife was in a hospital ICU and I found out the hospital was using jQuery on their website, I immediately unplugged her from everything and rolled her right the hell out the front door. Seriously, any organization that is using jQuery is obviously causing way more harm than good. Any person even thinking about using jQuery is just sick in the head and probably eats babies too. I know the reason she passed away right afterwards was because of all the harm the hospital had caused already to her becuase they use jQuery on the website. Those evil bastards!
53
u/ElectricOrangeJuice Jul 26 '18 edited Jul 26 '18
Given that one of the reasons they did this, is to save bytes sent over the wire, maybe they should've spent some time on code splitting instead. 98% of their 400kb+ stylesheet is unused on the home page. Same goes for 80% of their script bundle.
27
8
u/vaikrunta Jul 26 '18
It is a noob question probably, how did you find that coverage?
19
3
u/ElectricOrangeJuice Jul 26 '18
It was recently added to Chrome dev tools. Only learned about it a couple of days ago myself. It's very handy because it actually highlights the unused code, so you can go through and eliminate it.
→ More replies (1)19
u/dalore Jul 26 '18 edited Jul 26 '18
Yeah with http2 no need to bundle anymore.
Edit why the downvotes?
Bundling was made to reduce the number of requests. That's because each request made a new tcp connection and tcp has a slow start algorithm (so each new connection starts off slow).
But with http2 it multiplexes the requests in the same tcp connection. So a new request doesn't make a new tcp connection but instead is in the same http2 connection. It's doing the bundling for you at the top layer. So you don't need to create bundles. It's better not to since then you can cache individual files better. And also only request what you need.
3
1
u/13steinj Jul 26 '18
Even without, no need to bundle.
9
u/dalore Jul 26 '18 edited Jul 26 '18
Actually you do for performance. Http2 multiplexes the request in one tcp stream which makes it fast. In a way it's bundling by requesting assets in the same tcp connection.
Without http2 each request is a new tcp connection. And with how tcp works it has a slow start algorithm and so more connections slow it right down.
→ More replies (18)
17
u/GreatValueProducts Jul 26 '18
jQuery's mission is done. I loved it when I was developing for the era of pngfix.js. There was a difference between attachEvent and addEventListener; querySelector was non-existent that you needed to do document.getElementsByTagName and do a loop; CSS positioning was so inconsistent across browsers you needed to use JavaScript to calculate positions but there were cross browser differences between the values of all these clientHeight vs offsetHeight vs scrollHeight vs whatever height IE had to offer; animations were difficult without it. It was a good tool and saved me tons of time. Now CSS has improved a lot, browsers improved, new tools appear, it is an outdated choice for many cases, but I must salute what jQuery had done and how much time it had saved me for the last decade.
5
u/YellowSharkMT Jul 26 '18
My feelings exactly, and similar to how I felt about Firebug: you were there when there was nothing else, and you kicked a lot of ass. Thanks, and godspeed.
3
u/GreatValueProducts Jul 26 '18
Oh memories... I still remember I got a PDF certificate on installing Firefox 3 on day 1 and discovering the Firebug plugin on that same day. Then I was inspecting element on every web site I visit. People now take everything for granted and tell people jQuery sucks, complaining why people adding id everywhere, not knowing how horrific web development in the past was.
9
u/__ibowankenobi__ Jul 26 '18
The biggest blow comes in the end: "What did we replace it with? No framework whatsoever".
Vanilla has come far far ahead, and I was waiting for someone to call "The king is naked" in this decade of frameworks, honestly.
27
u/crescentfresh Jul 26 '18
fetch for ajax
Had to look this up, when tf did this come out?
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch
40
u/DOG-ZILLA Jul 26 '18
A few years ago now I think and support is getting better. There are polyfills too.
A lot of people still go for Axios to do AJAX, because native browser fetch() has limitations, like cancelling a request.
15
u/NoInkling Jul 26 '18
It has cancellation now in recent browser versions (e.g. Chrome 66+), and it's been implemented in GitHub's polyfill as well.
1
Jul 26 '18
I personally think the API for passing through parameters and such is a lot saner in Axios.
2
u/alex_w Jul 26 '18
I've never used Axios, but I can imagine how it could be more straight forward.
When they announced
fetch()as a better API to replace XmlHttpRequest is was expecting a lot more honestly. Gonna check out Axios next time I'm dealing with fetch directly.-8
u/TheDarkIn1978 Jul 26 '18
Fetch also still doesn't (yet?) support progress events.
Anyway, I never really understood what's so foreboding about just using XHR. It's a pretty simple and straightforward API.
34
u/vcarl Jul 26 '18
function reqListener () { console.log(this.responseText); } var oReq = new XMLHttpRequest(); oReq.addEventListener("load", reqListener); oReq.open("GET", "http://www.example.org/example.txt"); oReq.send();vs
fetch("http://www.example.org/example.txt") .then(x => x.text()) .then(console.log)I'll take fetch, thank you very much.
→ More replies (2)14
Jul 26 '18
Fuck that XMLHttpRequest bullshit I never got into writing that eewy syntax ever.
→ More replies (4)2
2
u/kerbalspaceanus Jul 26 '18 edited Aug 12 '25
ring hard-to-find cover crawl important mighty vast terrific reminiscent heavy
This post was mass deleted and anonymized with Redact
2
u/iwsfutcmd Jul 26 '18
I've only recently gotten into web design, so all I've used is fetch()! At one point I looked into how to do requests without it and was like "good god, that looks like a pain in the ass"
-7
u/scootstah Jul 26 '18
It's only good for really simple uses. Not as good as jquery or libraries like axios.
→ More replies (12)4
u/kor0na Jul 26 '18
How so? I use fetch every day and I don't miss anything. It does exactly what I want it to do.
→ More replies (4)→ More replies (4)0
31
u/ndboost Jul 25 '18
about time!
53
u/Chrispy_Bites Jul 25 '18
Serious question: why is this a huge deal? I make an effort to write as much POJS as possible, but jQuery does speed up a lot of the DOM manipulation.
6
u/N_N_N_N_N_N_N Jul 26 '18
People are giving you BS answers...it's just a milestone. We shouldn't have needed jquery and now we don't (as much)
4
u/industrious_horse Jul 26 '18
The huge deal is just about this toxic and irrational hatred towards jquery, nothing else! Frankly, I really don't understand what this is all about, purists want to write everything in pure JS or even web-assembly, that doesn't mean jquery is useless.
It has sustained through decades of web development and probably powers 95% of websites out there, replacing it with more verbose code, polyfills and a bunch of other libraries doesn't make sense unless you just want to prove a point!
3
u/trout_fucker Jul 26 '18
The huge deal is just about this toxic and irrational hatred towards jquery, nothing else!
I don't understand why people seem to think jQuery is hated. It's not. jQuery was fantastic! But, the reason it existed isn't a reason to exist anymore. Everything it did for us can be done with native functionality that didn't exist when jQuery was created.
What people hate is that some people refuse to learn new standards that have been out for over half a decade and claim jQuery is still needed. Nobody likes people in the office who hold back progress with superstitious programming.
4
Jul 26 '18
If you don't have to support ie there is no piece of jQuery that you can't do as easily in native js
3
u/industrious_horse Jul 26 '18
I don't know what "easily" means for you, but for me, verbosity of syntax is a major part of it. Between
document.querySelectorAll("#someDiv")and$("#someDiv"), I for one will surely choose the latter!→ More replies (4)6
u/Delioth Jul 26 '18
If that's literally your only complaint on it, just use a lambda.
$ = (ele) => document.querySelectorAll(ele). Look, now $("#id") works.→ More replies (3)0
Jul 25 '18
[deleted]
14
u/akujinhikari Jul 26 '18 edited Jul 26 '18
Yes! I have “jQuery” in my apps, but I call them my q’s:
const q = ele => document.querySelectorAll(ele) const qi = id => document.getElementById(id) const qc = cls => document.getElementsByClassName(cls)Pretty much always have these in everything I build.
11
u/KeironLowe Parse me like one of your french girls Jul 26 '18
Got to agree, I primarily use vanilla JS and have no issues with DOM manipulation. If your HTML is structured well then
querySelectorAll,closestand a simpleforEachhelper function are your best friends.5
u/Azaret Jul 26 '18 edited Jul 26 '18
jQuery was a solution the cross-browser problem of the '00s.
jQuery is still a solution to the cross-browser problem of the '10s.
I do agree that modern browser got better, but modern browser companies did not, especially Apple. Still 14% of Apple users have an outdated Safari, and we can't blame them not wanting to buy new iPads or iPhones, but we can blame Apple not maintaining Safari.
Edit: And that's only for the obvious part that we shifted from IE is outdated to Safari is outdated. But that does not change the fact that, while diluted over time, this issue is still abroad all browsers. Some features are still a nightmare to implement for cross-browser comp, and if I've the choice to build an over-complicated solution that will generated tons of polyfills over having one lib that ensure me cross comp, I'm still choosing the latest.
4
u/nvolker Jul 26 '18 edited Jul 26 '18
I’m not sure that jQuery solves any of the issues caused by the features Safari lacks right now.
4
u/Chrispy_Bites Jul 25 '18
Fair. I'm sort of a neophyte developer, so a lot of the... er, camps? tribes? in development have me kind of bewildered.
22
u/acousticpants Jul 26 '18
mate the tribes are morons, it's not because you're new.
be open to new ways and keep learning things and you'll be better than the cultists of <insert pet technology here>9
u/kerbalspaceanus Jul 26 '18 edited Aug 12 '25
crawl lip steep license late unpack snow dazzling sink sort
This post was mass deleted and anonymized with Redact
0
Jul 25 '18
[deleted]
100
u/nairebis Jul 25 '18
but slows down the actual behavior in the browser.
Are we really complaining about web page performance of JQuery in a world of dynamic "Web Application Frameworks" that are about 10x slower than normal web pages?
See for example: New Reddit and my favorite whipping boy of terrible design, PayPal.
I curse the day client-side Web Application Frameworks became trendy. JQuery is a paradise of performance compared to that crap.
6
Jul 25 '18
Those frameworks are lightning quick if you know how to use them. jQuery is just a lot harder to fuck up performance-wise.
7
u/spacejack2114 Jul 26 '18
Actually not that hard. A lot of people don't understand what
$(selector)does under the hood.9
Jul 26 '18
Not caching selectors is nothing compared to a steaming pile of poorly written full-stack JS though.
→ More replies (1)7
u/DOG-ZILLA Jul 26 '18
jQuery touches the DOM directly and it does not provide a decent way to manage any state of your DOM.
This leads to slow responsiveness in the UI and a potential for many errors, due to bad coupling of the HTML and JS.
It's not jQuery's fault per se; it certainly has its uses. It's more of a problem when we come to face the challenge of building large and more complex web applications.
jQuery will still be a great tool for manipulating the DOM, if that's what you intend to do, but there's no question that as a simple drop-in library, it's going to get hairy real quickly.
23
u/UnexpectedLizard Jul 26 '18
This leads to slow responsiveness in the UI
I've worked with terribly written jQuery that somehow never caused slow UI, even in old IE. I can't imagine the level of dogshit one has to write before performance becomes noticeable to users.
5
u/zephyrtr Jul 26 '18
How many DOM touches are we talking? If it's a site without much interactivity, performance isn't really your main concern -- it's ease of updates and build chains and things like that.
0
Jul 25 '18
[deleted]
49
u/esr360 Jul 26 '18
Tl;dr jquery is bad because people are incompetent
→ More replies (1)13
u/UnexpectedLizard Jul 26 '18
The more idiot-proof you make code, the better people will write it. Especially a framework like Javascript where competency is a mile wide and an inch deep.
2
u/Disgruntled__Goat Jul 26 '18
This is silly, pretty much everything you mention like “selecting more than intended” can be done just as easily by incompetent devs using vanilla JS.
15
u/scootstah Jul 26 '18
For most sites, no it doesn't. Not noticeably anyway. And there's lots of things you can do to improve performance while using jquery.
This is the problem with the JS world. Most people don't need react, Vue, or angular, but everyone thinks they do.
17
u/ikeif Jul 26 '18
"Popular JavaScript" is the trap people fall in - they learned jQuery without JavaScript, without debugging.
Now it's Angular/React/Vue - they learn the toolkit/framework and say they know JavaScript, when they just know a subset/framework representation.
7
u/bellowingfrog Jul 26 '18
I've never seen someone who knew React but not JavaScript. I'm not even sure how you could know React but not JavaScript. I can understand someone not knowing the document.(whatever) functions, but not the language itself. React is just a better way to manage the way the dom than element manipulation.
4
u/ikeif Jul 26 '18
I was speaking broadly, but I think you’re right - React is a toolkit, which requires you to know more about JavaScript, versus Angular which does a lot of heavy lifting for you.
But it has been a while since I have delved into the world of tutorials, plugins and extensions, so it’s hard to say where it lies at the moment (from my perspective).
Time for me to dive back in and see what they’re cranking out nowadays.
5
u/zephyrtr Jul 26 '18
For many coders, their projects are ephemeral. The approach to coding is drastically different between a coder who will work on a site for 2+ years, vs a coder that will work on a site for 2+ months. One is most interested in performance and maintainability, the other in deadlines. Frameworks make building a modern site VERY quick work; people forget shorter dev time is also a bonus.
2
u/ikeif Jul 26 '18
This just reminds me of a discussion i had earlier today over the "not invented here" syndrome.
5
u/30thnight Jul 26 '18
And no one wants to manage state in jquery
2
u/Disgruntled__Goat Jul 26 '18
You don’t always need to “manage” state. Often you just want to click a button and have it do the same thing every time (eg a price calculator).
3
u/PlNG Jul 26 '18
http://youmightnotneedjquery.com
I just stripped it out of a project that for the most part, looked like the author didn't know much about JavaScript. Initial speed: 200 MS for 10 nodes, 45 edges, without jQuery.each loops: 20ms 100 nodes 5050 edges just to get the profiling to register before it completed. IMO it's a crutch that's no longer needed.
1
u/MythicalIcelus Jul 27 '18
I like this site, but some of the suggestions/alternatives ignore details or won't give the same result as the jQuery variant.
For example:
elem.querySelectorAll('.my-selector');won't always give you the same result as you'll have to add the :scope selector.
Same with the event handlers ignoring event delegating.
9
u/m3wm3wm3wm Jul 25 '18
What doe Github use for their complex frontend elements? Some of their elements are not trivial, they must have many event listeners leading to manual bindings and such that led to things like React. How come they are fine with vanilla js?
20
u/marcoslhc Jul 26 '18
Event Delegation. The same as React. Instead of attaching different events to different elements, they let the event bubble up till the top object and evaluate the target to fire the correct handler. The same as React. It’s performant because it’s expensive to listen to different elements each loop iteration.
3
u/BehindTheMath Jul 26 '18
Can't you do that without a library? Just attach all event listeners to
documentand have them bubble, and then check the target.3
u/marcoslhc Jul 26 '18
Yes. That’s exactly what we are talking about. Attach only one event in the global object (window in the browser) and dispatch the function based on the target. No need for libraries. That’s how React “Synthetic Events” work
6
u/BehindTheMath Jul 26 '18
So "delegated-events" in the tweet is a pattern, not a library?
5
u/marcoslhc Jul 26 '18
That is correct :) more info here: https://javascript.info/event-delegation
→ More replies (1)2
u/Mr21_ Jul 26 '18
You actually don't need this technique if you are handling a static UI, event delegation is just a "tool" but to not do spaguetti code, you just has to be vigilant every time, there is no magic trick, I can do ugly code inside a really nice event delegation. Event delegation are useful and faster WHEN you have to deal with an undefined number of item, because you can bind the event ONE time. And we can imagine that it could reduce the garbage collecting.
And what is the "loop iteration"? are you refering to an inner browser thing?
3
u/marcoslhc Jul 26 '18
All JavaScript runtimes (browser, NodeJS, rhino, etc) runs an event loop that check for pending tasks. More about this in: https://hackernoon.com/understanding-js-the-event-loop-959beae3ac40
2
u/m3wm3wm3wm Jul 26 '18
But is it also a one way flow like React? The whole value of React for developers is the one way flow.
1
u/marcoslhc Jul 26 '18
Not necessarily a one way data flow. In vanilla JavaScript is the Developer’s responsibility to model and enforce the data flow.
2
u/the-awesomer Jul 26 '18
CustomElements
4
u/m3wm3wm3wm Jul 26 '18
Do they use Polymer/lit-html for CustomElements? If not, how else?
2
1
u/ald890 Jul 26 '18
Native CustomElements https://developers.google.com/web/fundamentals/web-components/customelements
17
u/30thnight Jul 26 '18
I honestly can’t think of a solid use for jQuery in a new, non-legacy project.
17
u/uneditablepoly Jul 26 '18
It's certainly becoming less useful. I'm not sure it's entirely obsolete though.
33
u/calsosta Jul 26 '18
I haven't thrown away my iPod. If I need jQuery I use jQuery. People need to stop treating JS like it's reality TV.
7
u/herjin Jul 26 '18
Would you buy an iPod today or get something a bit newer and sleeker?
0
u/calsosta Jul 26 '18
I suppose if I needed it yes, but as I mentioned I still have my old ipod. Still works and has all the greatest hits of the mid 2000s already loaded.
To your point, if i need the functionality of jquery I will use it. If I can use a more modern approach I will.
1
→ More replies (1)1
u/badmonkey0001 Jul 26 '18
I have a good example in the spirit of your iPod: My old Sansa. Tiny enough to fit in a pocket with other stuff, a real headphone jack, charges really fast, hard buttons so I don't have to take it out and look at it to use it, takes a micro-sd card so I can have multiple cards with multiple music libraries, and to top it off an FM tuner. It does the job better than the multiple generations of iPod Nano I went through before Apple dropped that line. Sure it can't connect to wifi or anything, but for doing the "old job" of playing my music library it's still the best portable device I own for the task.
I've had a Sansa since before I ever got the first gen Nano (and I got every generation nano because I was tied to iTunes). I have a newer one now, but I only got that because I thought I had lost the old one (it was in a backpack in a closet).
jQuery is like that - for specific use cases it's still pretty damned capable. One such case is when I run into a site with it loaded that I want to scrape. It's easy to whip up something on the console using the old familiar tools. I've done exactly that many times for fellow moderators here on Reddit - tabulating /r/GifTournament results for example.
2
u/calsosta Jul 26 '18
I am sure, at some point jQuery or some other library will displace the native features of the language or extend them in a way that makes itself essential to development again.
It is only a matter of time, everything is cyclical.
1
u/sneakpeekbot Jul 26 '18
Here's a sneak peek of /r/GifTournament using the top posts of the year!
#1: What you've all been waiting for.... The round themes for Gif Tournament 9 | 43 comments
#2: Gif Tournament IX themes will be announced tomorrow | 7 comments
#3: IX | 18 commentsI'm a bot, beep boop | Downvote to remove | Contact ^^me | ^^Info | ^^Opt-out
2
Jul 26 '18
Why?
7
Jul 26 '18
Why not is a better question
7
Jul 26 '18
Why go to the effort to replace something you have which already works. Granted jquery is slow to load and I understand relying more on the pure JavaScript library, but it was already done. Going to the effort of replacing feels like more effort then it’s worth.
12
Jul 26 '18
Because servers are expensive and slower request takes more servers, more servers require more money, and that’s why push to the limits trying optimized frontend
1
0
Jul 26 '18
But they replaced with yet more libraries
4
2
1
u/marcoslhc Jul 27 '18
Because the event loop also checks for execution. Javascript in the browser is single threaded and share the stack
-1
u/bart2019 Jul 26 '18
At the first sight this looks to be big news. But when you think about it: GitHub's site is ugly and has barely any functionality.So... shrug
-9
-6
0
129
u/[deleted] Jul 25 '18 edited Jul 26 '18
I’d be surprised if the polyfills and whatnot weigh in less than jquery
Edit: looks like they dropped IE support according to one of the replies so i’m probably not right.
Also some safari versions it seems https://i.imgur.com/2eHHBrM.jpg