Live data from Hacker News

You might not need jQuery

youmightnotneedjquery.com

61–70 of 360 posts

Re: You might not need jQuery

#61
post #59
post #53

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 have it a bit backwards, IE8 doesn't include JSON support when you are in quirks mode, which no modern application should ever be in.

Re: You might not need jQuery

#62

Couple 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

Are you animating the transform/opacity properties and only those? That's the general secret to smooth animations on web - they're GPU accelerated, everything else requires a call into the browser's layout engine on every frame.

Re: You might not need jQuery

#63
post #32

So, 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.

Could you elaborate on how jQuery creates vertically-stacking dependencies and library conflicts by itself?

Re: You might not need jQuery

#64
post #57

No, 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…

100% agree!

Re: You might not need jQuery

#67
post #48

Greenspun'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…

The question at hand is, are fallbacks necessary anymore for the browsers we are targeting today?

Re: You might not need jQuery

#68
post #57

No, 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…

Fantastic point. Abstractions can be dangerous because they often aren't developed right.

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

#69

Couple 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…

Transitions didn't end up being supported until IE10, which wouldn't jive with the IE8+ baseline the site proposes.

Re: You might not need jQuery

#70
post #65

Articles 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.

One could ask if that's actually a good thing.

You also get the same thing from the existential operator in coffeescript, if you're in to that.

Post reply on HN