The Bad: The premise of the examples list seems a bit disingenuous. Very few of these things take into account the full convenience of jQuery. It's much more than saving a couple lines of code or knowing the native way to accomplish the most basic version of a task. jQuery's real benefit is preserving simplicity as your needs grow more complex. Right off the bat I feel like the getJSON[1] example is a bit simplistic.…
right off the bat its wrong, IE8 doesn't include JSON support unless you're in strict mode.
You might not need jQuery
61–70 of 360 posts
Re: You might not need jQuery
#62Couple improvements to some of the modern-browser code examples: FadeIn: element.style.transition = 'opacity 400ms ease-in-out'; element.style.opacity = 1; Each & filter (this also applies to people's complaints about browser methods not working on collections): [].forEach.call(document.querySelectorAll(selector), function(el) { ... }) The native versions also usually run several times faster than the JQuery versions…
I've had pretty terrible performance with complicated CSS animations that I managed to clear up with switching to JavaScript and requestAnimationFrame
Re: You might not need jQuery
#63So, uh, what will I gain by ditching jQuery? I will lose a beautiful API with a simple, terse and familiar syntax. I will have to work with an ugly, inconsistent and loquacious API, which has no guarantee of being cross-browser (or accounting for various browser quirks). And for what? I doubt 81 KB would make much difference to 99.9% of my visitors. As for performance -- it makes sense to rewrite bottlenecks in pure…
You lose dependency on a monolithic library which creates vertically-stacking dependencies and library conflicts. By ditching it, you gain the ability to construct your app out of loosely-bound components supported by independent developers.
Re: You might not need jQuery
#64No, please no. If size is an issue for some reason or you want to have no dependencies you can use something like http://zeptojs.com/ and just embed everything in one minified file. If you do things right only the functions you are actually using will get placed in there as well. Do not reinvent the wheel to solve problems that can't be solved in much cleaner and nicer ways. Managing dependencies can be annoying, but…
Re: You might not need jQuery
#65Re: You might not need jQuery
#66Re: You might not need jQuery
#67Greenspun's Tenth, updated for 2014: "Any sufficiently complicated website contains an ad-hoc, informally-specified bug-ridden slow implementation of half of jQuery" I understand the visceral opposition, but once you start writing a fallback to support some browser (something to support IE or FF or Safari or Chrome ...) you might as well use the battle-tested solution (and write your own thing if you find performance…
Re: You might not need jQuery
#68No, please no. If size is an issue for some reason or you want to have no dependencies you can use something like http://zeptojs.com/ and just embed everything in one minified file. If you do things right only the functions you are actually using will get placed in there as well. Do not reinvent the wheel to solve problems that can't be solved in much cleaner and nicer ways. Managing dependencies can be annoying, but…
But that isn't the case here. When something like jQuery comes along, hiding so many gory details, and has been tested to death both in development and in production use all over the world, we are all better off because we remove so much failure surface area from our code.
Re: You might not need jQuery
#69Couple improvements to some of the modern-browser code examples: FadeIn: element.style.transition = 'opacity 400ms ease-in-out'; element.style.opacity = 1; Each & filter (this also applies to people's complaints about browser methods not working on collections): [].forEach.call(document.querySelectorAll(selector), function(el) { ... }) The native versions also usually run several times faster than the JQuery versions…
Re: You might not need jQuery
#70Articles like this miss the _true_ genius of jQuery – that it basically wraps all DOM operations in a maybe monad. You get null safety for free.
You also get the same thing from the existential operator in coffeescript, if you're in to that.