Live data from Hacker News

You might not need jQuery

youmightnotneedjquery.com

181–190 of 360 posts

Re: You might not need jQuery

#181

Earlier quoted context omitted.

If you are developing a library, then your users _Might_ need to support old browsers and _Might_ need jQuery.

lots of js libs are for things like webgl that already dictate a recent browser.

and I care about wether my site works on Safari or Android 2.3 browsers. Will you fix all the "wont fix" DOM bugs for me?

Re: You might not need jQuery

#183
post #146

Earlier quoted context omitted.

> jQuery was born in 2006, when IE6 still had 70% of market share. jQuery's many layers of smooth-overs come at a very high performance cost, and it doesn't even smooth things over that well. There are still many edge cases in event handling such as triggering a click that bubbles on a detached element on Webkit that jQuery just can't do for you. Shouldn't you aim to provide the best experience for the 50-80% of user…

Nope. jQuery 2 just removed code for IE 6/7/8. Nothing was added. Code sized reduced, but almost the same performance. My benchmark shows only 10-15% improvement. That's nothing compared to using the DOM API straight up.

Care to substantiate your benchmark where you compare jQ1, jQ2, and the native DOM API?

Re: You might not need jQuery

#184

Earlier quoted context omitted.

More to test than you thought. That just broke more than 20% of the Android installed base, since Android 2.3 doesn't work with classList.

A classList polyfill is like 500b compressed. No need to blow a non-existent problem out of proportion. https://github.com/remy/polyfills/blob/master/classList.js

are you serious ? thats actually a good example on why you should use jquery. First of all the dev needs to know exactly on which platforms he will run into problems and how to solve them...And what if you need not one but several polyfills ? That gets messy pretty quickly.

Re: You might not need jQuery

#185
post #8

Earlier quoted context omitted.

It sounds like you're looking for the querySelector and querySelectorAll methods: https://developer.mozilla.org/en-US/docs/Web/API/Document.qu...

querySelector and querySelectorAll could have been pretty great, but they suffer from some serious problems as they ended up spec'd. The one I hate most is that qSA returns Yet Another JavaScript Collection That Is A Lot Like An Array But Isn't An Array And Therefore Doesn't Have Any Of The Nice Methods(TM). Yes, you're going to have to iterate over the thing using an index in a loop. There's others: http://ejohn.org…

    Array.prototype.slice.call(document.querySelectorAll('.myClass'), 0);
Or if you want to abstract that into a utility function:

    function qsa(sel) {
        return Array.prototype.slice.call(document.querySelectorAll(sel), 0);
    }

    qsa('.myClass'); // Returns array of elements

Re: You might not need jQuery

#186

AngularJS is all you need.

Citing the AngularJS FAQs:

Does Angular use the jQuery library?

Yes, Angular can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

Due to a change to use on()/off() rather than bind()/unbind(), Angular 1.2 only operates with jQuery 1.7.1 or above.

http://docs.angularjs.org/misc/faq

Re: You might not need jQuery

#187
This is fascinating to me since I'm already moving away from jQuery. I'm always looking for other ways to do what many people use jQuery for. For example, I'm now using CSS3 animations and transitions instead of jQuery.

I've also started using Angular.js quite a bit and have found most of the time, it requires less code than jQuery. It also has its own subset of jQuery "jqLite" which has a much smaller footprint so your app doesn't need to rely on that jQuery dependency.

Re: You might not need jQuery

#188

I feel empathy for the OP, for two main reasons: 1) The fact that some people don't realize that JavaScript != jQuery scares me. 2) jQuery born when cross-browser compatibility was a mess and today it still carries that weight. I think nowadays it needs to be more modular and less monolithic.

> 1) The fact that some people don't realize that JavaScript != jQuery scares me.

DOM != Javascript

That's the thing you dont understand and makes you say silly things.

Re: You might not need jQuery

#189
jQuery still has it's uses... like when it's essential to have consistent support across browsers old & new. However I much prefer to tell users who insist on using out-of-date/poorly-built browsers to upgrade or fuck off, hopefully gently encouraging them to do so.

Re: You might not need jQuery

#190

I would like to add a thought about the dispute about the need of using jQuery. Let's say we know a consultant, let's call him Bob, who works on client projects. He needs to implement new features fast, and does not want to worry about low level stuff. Once he's done with a project, he moves on to another. Then, we meet a JS-framework developer, let's call her Alice. She has to weight every line of code she writes be…

Thank you. Its astounding how much of this thread does not seem to be catching this.

My project currently depends on libraries which in turn have dependencies on mutually exclusive versions of jQuery, so we conditionally load a whole second copy some of the time. I've been meaning to fix the libraries that require older jQuery so we can fix this, but the bugs run deep, the libraries are pretty unmaintainable, and I'm under pressure to keep shipping features.

Post reply on HN