Hacker News new | past | comments | ask | show | jobs | submit login

jQuery was invaluable 5+ years ago, but luckily it's not needed for most modern web projects, unless you need to support old IE browsers. Even then, it's worth seeing how many calls you really need to make that are not supported across your target browsers.



> but luckily it's not needed for most modern web projects, unless you need to support old IE browsers.

I disagree. While I am building our actual app in Angular, our landing page and that still uses jQuery for things such as ajax requests. There's no need to pull in any major framework like Angular for such tasks.

jQuery still has a lot of relevancy in the web.


I would say the landing page is exactly the case where jQuery is not needed anymore. Yes, it's convenient to use, yet for a mostly static page with a few XHR calls, some DOM interactions and whatnot - it's a bloat, actually. 12-16 months ago it would be a sabotage in most cases, but once it's all OK to forget about IE8 - you really can put the good ol' DOM-AJAX-animation JS libraries to rest.

From personal experience: just few days ago I've made a landing page. Focus was on mobile and performance so no jQuery, modernizr, lo-dash, and so on. We only grabbed some syntatic sugar from microjs.com so we could write $(el).remove() instead of el.parentNode.removeChild(el);, etc.

Turned out a nice, little page with all the usual bells and whistles only really needs a 12KB of JavaScript code (uncompressed). We actually missed lo-dash more than jQuery.

In age of "modern browsers'" ubiquity, and Angular/React/Ember/MV* libraries doing the heavier stuff, the support for older IEs is really the last selling point of jQuery. And that goes away soon.

P.S. Very handy: http://youmightnotneedjquery.com/


> it's a bloat, actually.

I mean, it's like less than 30kB minified+gzipped, and if you load it from a CDN, then there's a 95% your users already have it cached.

I guess it's technically a "bloat" but unless all your images are gzipped SVGs, it's almost certainly one of the smaller elements in your page.


Unless you're using the unversioned ("latest") jQuery version on your CDN, the browser cache hit rate will be way less than 95%. I've seen some estimates at less than 20% (can't find the link at the moment).

And for various reasons, it's not a terribly good reason to use the "latest" jQuery version with no version, unless you're prepared to deal with sudden code breakage.


> then there's a 95% your users already have it cached.

In reality, there's a less than 5% chance that your users will have the right version cached, but a 95% chance that your users will notice when the public CDN is over capacity.


React isn't really a framework like Angular or Ember. Remember that it's view only - it doesn't handle ajax calls, routing, error handling, async code, etc.


I'd argue you are pulling in a large library that has much more functionality and bloat than you actually need. For ajax, I'd prefer something like axios which uses es6 niceties like Promises and is much more targeted in its usage.

jQuery was originally a bridge for the gaps between browsers for lots of basic functionality. These days, all modern browsers give you a decent starting point with plain js, meaning there's not a whole lot of things that you really need jQuery for. Secondly, you mention that you are using angular, which already provides its own $http and $resource libraries for ajax... which I think shows even further that you don't actually need jQuery.


He's using jQuery on a separate landing page which is not part of his Angular app.

I do wish jQuery would update to support ES2015 module exports so I could do something like import { ajax } from 'jquery';


You load all of jQuery for just Ajax? I'd just use `fetch` or one of the many small Ajax utilities plus `querySelectorAll`—though I'll admit I don't know their browser support status.


No I use it for more than that, the landing page is built on Bootstrap, so I have modals and other fun stuff that Bootstrap + jQuery bring to the table.


I completely disagree. Need to write a bit of javascript for a page, or a small app? I'm never gonna go the angular or the react route. I'm just gonna do that in 5 minutes using jQuery.


You misunderstand. I'm definitely not suggesting using Angular or React for a page or small app. Quite the opposite. I'm suggesting using just Javascript, with no libraries.

As other posters have written here, you can easily now do just about everything on "Vanilla JS" as you can using jQuery. In my experience, the possible exception to this are animations which require significant boilerplate. However, most common animations are now extremely trivial to accomplish using CSS.

I haven't used jQuery for new project in 2 years, unless I have to support less than IE9 (and even then, I make sure I really need it first).


> you can easily now do just about everything on "Vanilla JS" as you can using jQuery.

jQuery is vanilla JavaScript. As a full stack JavaScript developer, it pains me that people think that something written in JavaScript isn't vanilla JavaScript. It is.


> you can easily now do just about everything on "Vanilla JS" as you can using jQuery

yeah if you are a masochist


> luckily it's not needed for most modern web projects

Alright, technically it's not 'needed' for any web projects. But it sure can help in a lot of ways on a lot of projects.


> But it sure can help in a lot of ways on a lot of projects.

On modern browsers? Can you give me an example?


Three ways it can help:

* A lot of plugins/libraries require jQuery, so by using jQuery you can use those plugins.

* It's easier to hire junior devs that can write good enough jQuery, compared to native JavaScript.

* As a very mature library, there's lots of documentation out there for standardising the way you do things. This makes it easier for other devs to pick up your work.


> A lot of plugins/libraries require jQuery, so by using jQuery you can use those plugins.

I'm seeing more and more mature "Vanilla JS" libraries for common tasks I used to use jQuery plugins for. But yes, if you must have some plugin, then you have to use jQuery. In that case, it's probably not worth the time to re-write the plugin in Vanilla js unless you have some specific bandwidth constraints among your users.

> It's easier to hire junior devs that can write good enough jQuery, compared to native JavaScript.

Sadly, you're probably right about this. I'm a little uncomfortable with the term "native" JavaScript since that makes some devs think it's some kind of OS hacker-level of difficulty, when in fact, most jQuery equivalents in modern JS are quite similar to...jQuery.

> As a very mature library, there's lots of documentation out there for standardising the way you do things. This makes it easier for other devs to pick up your work.

Sure, I can see this being true. I guess if you have to hire and train a bunch of relatively middle-of-the road junior developers, jQuery is a good choice at the moment. But even if I were in your position, I'd still try to push them to get used to writing in vanilla JS. This is good not only for your project, but also for them, since more and more employers, even mediocre employers, will start expecting potential frontend dev employees to be able to write vanilla JS.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: