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…
The second function is broken for an element with multiple classes. DOM fail.
You Don't Need JQuery
51–60 of 201 posts
Re: You Don't Need JQuery
#52Every 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…
Yeah, the problem with jQuery is all that other stuff that nobody uses and backwards compatibility with browsers nobody supports. A "lite" jQuery with the same familiar API but a stripped-down featureset for higher performance and smaller size would be nice.
Re: You Don't Need JQuery
#53Re: You Don't Need JQuery
#54You 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…
Re: You Don't Need JQuery
#55Re: You Don't Need JQuery
#56You 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…
.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
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
#57So no, I disagree. Stupid article.
Re: You Don't Need JQuery
#58Another great resource when trimming down jquery use is http://youmightnotneedjquery.com/
http://youmightnotnotneedjquery.com/
or
https://gist.github.com/rwaldron/8720084#file-reasons-md (discussion: https://news.ycombinator.com/item?id=7153630)
Re: You Don't Need JQuery
#59Earlier quoted context omitted.
Life is definitely too short to not be using npm, browserify and React! https://www.npmjs.com/package/browserify https://www.npmjs.com/package/react And then use just what modules you need. All the functionality of jQuery has already been ported to various modules. https://www.npmjs.com/package/extend https://www.npmjs.com/package/promise https://www.npmjs.com/package/serialize-form
> Life is definitely too short to not be using npm, browserify and React! These are all cool things, but sometimes you want to simply make a web page without setting up node and npm and all that jazz. Think of it this way... jQuery is like getting a subset of the most common functions you get by using in browserify, but without requiring a build step!
jQuery's imperative DOM manipulation is a horrible way to manage state compared to React.
These tools aren't just "cool things". They were designed to solve really pressing issues related to managing complexity in front-end web applications by eliminating global state in both the DOM or the JS runtime environment. They tend towards a more declarative and functional approach to system design.
A build process that integrates with a versioned package manager is fantastic.