Earlier quoted context omitted.
`$(".foo").removeClass("bold")` becomes the wonderfully concise [].map.call(document.querySelectorAll(".foo"), function(node) { node.classlist.remove("bold"); })
This may seem anecdotal, but I can tell you from writing a lot of non-jQueryified code that with modern browsers, applying classes to dozens of elements dynamically can be an anti-pattern. 99% of the time, when doing something which previously would have required that, I can use a single class on a parent element.
You Don't Need JQuery
91–100 of 201 posts
Re: You Don't Need JQuery
#92You 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...
Re: You Don't Need JQuery
#93Earlier 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
before jQuery I always defined an ID method like: function ID(id) { return document.getElementById(id); } saved some typing. I'll always try to use jQuery now though, bigger problems to solve.. few extra bytes to download is not that bad...
Re: You Don't Need JQuery
#94Fear or Love on the web developer scale of needs.
Re: You Don't Need JQuery
#95For the eco-system point of view, jQuery have been tested in the widest markets for many many years. well written document, many online cases, many supporters, many bug reporters, high cover unit tests,good code quality and so on.
Using jQuery for project is smart move unless high performance requirement.
Re: You Don't Need JQuery
#96Yeah, you don't need anything. You can write all your apps in vanilla JS, but if you feel like speeding up development...
and slowing down your website
Re: You Don't Need JQuery
#97Earlier 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…
Re: You Don't Need JQuery
#98You 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…
So this:
document.getElementById('foo').className =
document.getElementById('foo').className.replace(/^bold$/, '');
Can become to this: foo.classList.remove("x");
And is miles away more performant than slow jQuery.Re: You Don't Need JQuery
#99Lots of blanket statements in this article. He asserts there is a 'proper' order to learning JavaScript but makes no demonstration of that assertion. For me, jQuery was a gateway that hid much of the incidental complexity of working with a byzantine API (the dom). That was incredibly useful. If every beginner started with trying to understand the DOM, they'd probably be scared off (and rightly so).
What you call Byzantine, I call normal. Some things are harder to learn than others but you can't throw your hands up in the air and let someone else (jQuery) do the simple things for you. Working with the DOM is what we programmers do. I've never seen so many people complain so much about programming than those who use jQuery.
Re: You Don't Need JQuery
#100You 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...