Live data from Hacker News

You Don't Need JQuery

blog.garstasio.com

81–90 of 201 posts

Re: You Don't Need JQuery

#81
post #26

Earlier quoted context omitted.

.classlist() [1] is coming [2]. It'll allow you to do: document.getElementById('foo').classList.remove("bold"); Sure, it's still more verbose. But a lot of what jQuery does is slowly being obsoleted by better native javascript apis. [1] https://developer.mozilla.org/en-US/docs/Web/API/Element.cla... [2] http://caniuse.com/#feat=classlist

So when those new native api functions arrive, jQuery will start using them and gain some performance boost (using native vs. custom js code) while at the same time remaining backwards compatible (by doing feature detection). No one wants to write their own feature detection code so this whole page about using native apis is instead of jQuery is ridiculous. If the point of that website was to educate people on the ap…

You hit the nail on the head.

Re: You Don't Need JQuery

#82
Actually I think the biggest reason to use jQuery is the plugin ecosystem. Think about it... if you want to do _anything_ there is a jQuery plugin already written to do it.

Re: You Don't Need JQuery

#83

When I first read this post, I thought the link may be to this website: http://youmightnotneedjquery.com/ . I developed a Cordova application recently, and I only needed jQuery for Bootstrap. All custom JS was able to be done using the DOM API. However, I was spoiled since I only had to develop against a recent webkit version (my target was iOS 7)

I had the same feeling when started working with angular, were you don't need jQuery or anything else to manipulate the DOM. It is spoiled, I agree, but it feels good to be "free" :p

Re: You Don't Need JQuery

#84
post #17

Every time I try to build something without jQuery, I regret it. Not because of selectors, that's (sometimes) easy to do for lots of (basic) selectors. Not because of DOM manipulation, as long as you're willing to sacrifice simplicity and readability, you can build iterative loops to modify a collection of HTML elements. No, it's the unexpected things that cause me pain. Want to use event handlers on dynamically gene…

There are other libraries though which provide (IMHO better) implementations of each of those things. jQuery has been around for ten years and has to remain backwards compatible. It's just not possible for it to be the best implementation of Promises, or AJAX or any of the other individual things it does. Real bundling with tools like Browserify is making it more and more feasible to use single-purpose libraries inst…

The thing is there's always other libraries that provide better implementations of things. Likely the instant you pick one, there will be something "better". jQuery has the benefit of being as much of a standard library for the web as anything else. Often it's not worth the time and effort to hunt down the absolute perfect combination of libraries to accomplish the same thing.

Re: You Don't Need JQuery

#85
Articles like this make me thankful that I've done my 10,000 hours of web development learning the ins and outs of the DOM and it's interactions with JavaScript (mostly topics covered in Crockford's book). Admittedly, about 9,950 of those hours were making it work in IE6.

jQuery is a framework, like many others. Programming is not about learning frameworks, it's about learning the language, it's runtime behaviours and of course software development in general. Frameworks are there to speed up development time.

Re: You Don't Need JQuery

#86
post #14
post #7

You can basically sum up this entire rather ridiculous site with "Yes, you don't need jQuery, you can just use the built-in methods, but using jQuery is generally more pleasant, more consistent, and involves less typing". One particularly egregious example from the site: $('#foo').removeClass('bold'); vs. document.getElementById('foo').className = document.getElementById('foo').className.replace(/^bold$/, ''); The au…

document.getElementById('foo').classList.remove('bold'); see https://developer.mozilla.org/en-US/docs/Web/API/Element.cla...

Only since IE10.

Re: You Don't Need JQuery

#89

Right off the bat, on the first 3 examples, he shows how you need to use different APIs depending on the IE version. That alone is enough reason to use jQuery and not having to bother.

You're pointing out an IE problem, not a javascript problem that isn't present in other browsers.

[deleted]

Re: You Don't Need JQuery

#90
post #7

You can basically sum up this entire rather ridiculous site with "Yes, you don't need jQuery, you can just use the built-in methods, but using jQuery is generally more pleasant, more consistent, and involves less typing". One particularly egregious example from the site: $('#foo').removeClass('bold'); vs. document.getElementById('foo').className = document.getElementById('foo').className.replace(/^bold$/, ''); The au…

It's like saying "You don't need a web browser at all -- See how we can navigate the web using cURL!"

Come on. Lynx is the browser.
Post reply on HN