http://youmightnotneedjquery.com/
jQuery 3.0 Released
21–30 of 164 posts
Re: jQuery 3.0 Released
#22Re: jQuery 3.0 Released
#23http://youmightnotneedjquery.com/
To me, all of the JQuery examples are much nicer to read and write. Sure, you can use raw JS, but why copy annoying boilerplate? (I'm not a JS dev, so I don't have a dog in this fight).
Re: jQuery 3.0 Released
#24http://youmightnotneedjquery.com/
Is that comparison supposed to show that jQuery is bad or what exactly? Because it's clear that jQuery is much more concise in every single case.
Re: jQuery 3.0 Released
#25Is anybody in the HN crowd still using jQuery for new projects? If yes, why not use "vanilla" js?
Re: jQuery 3.0 Released
#26Earlier quoted context omitted.
So far every new project in the last few years ended up using jQuery because there is always this one ui widget that does what we need and the other libraries just aren't there yet and its not worth the hassle of reimplementing or extending a different library just to not use jQuery.
True. Although whenever I see a jQuery plugin like that I try to replace it with some combination of "components" [1]. There is a lot of progress in that area. There are stuff like : File picker [2], dropdown [3], tip [4] for tooltips and many more. 1 : https://github.com/component 2 : https://github.com/component/file-picker 3 : https://github.com/component/dropdown 4 : http://component.github.io/tip/
Re: jQuery 3.0 Released
#27Consider the relatively common use-case - there is a service object which proxies requests, format's the call to the backend (or fetches from cache) and format's the returned response for the caller of the object. So the pattern looks something like: ServiceObject.fetchData(query).then((data) => { / * display data * / }, (err)=> { / * catch error - display no results * /})
At some-point you want to chain the promise to update another part of the ui: promise.then((data) => { /* display something else / }, (err) => { / catch error - display failed to load */ }).
The problem is you can't squash the error in the 'reject' of the previous promise now, because otherwise the error isn't propagated to the last promise in the link and instead you will hit the 'success' function. This 'reject' behavior is alright if there is something your 'success' function can do when the original request failed, but in a great majority of cases if the request failed there is nothing you can do - you put a 'reject' in the first chain of the promise resolution (potentially in the serviceObject itself) with some generic flash-message like 'request failed please try again' and call it good. As it stands you end up with a call chain where what a function higher up in the chain should return should be based on what a resolving function further down the chain is doing -- not having to do this was for me was almost entirely the plus-side of the promise-style over callbacks-style concurrency model.
I bring this up now because curiously the jQuery model of Deferred() precisely did not do this before -(see section#2 of Major Changes):
> Example: returns from rejection callbacks
if an error wasn't re-thrown in a catch, the promise-handling would stay in the 'reject' chain as long as an error had been thrown. I am quite curious as to why the current-model won, I understand some of the potential benefits but in practice I find that this behavior is worse in 90% of use-cases that I have encountered. If someone has a link to a mailing-thread / issue where this was discussed I would be quite interested.
Re: jQuery 3.0 Released
#28Is anybody in the HN crowd still using jQuery for new projects? If yes, why not use "vanilla" js?
Re: jQuery 3.0 Released
#29Is anybody in the HN crowd still using jQuery for new projects? If yes, why not use "vanilla" js?
something like $("#wrapperel").on("click",".painbutton",cbfunction),is way more code in plain js.
Re: jQuery 3.0 Released
#30It's a controversial notion, I'll grant, but what if the DOM APIs had been replaced by "native" jQuery support? Would we have been better off? Worse?
Considering the intricacies of standards bodies and industry lobbies, pondering the pros and cons makes for a fascinating exercise.