Live data from Hacker News

jQuery 3.0 Released

jquery.com

21–30 of 164 posts

Re: jQuery 3.0 Released

#23
post #10
post #3

http://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).

The authors of that page seem to be making their suggestions principally for library authors, to avoid an otherwise unnecessary dependency on jquery.

Re: jQuery 3.0 Released

#24
post #14
post #3

http://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.

No. That site is giving helpful alternatives so that library authors can avoid having jquery as a dependency.

Re: jQuery 3.0 Released

#26
post #8

Earlier 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/

What is this "components"? I can't find anywhere that explains what it is. Is it just a random collection of javascript utilities?

Re: jQuery 3.0 Released

#27
I've complained a few times about what seems to me, to be a less-friendly way of handling Promise rejections in es6.

Consider 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

#29

Is anybody in the HN crowd still using jQuery for new projects? If yes, why not use "vanilla" js?

because its often less verbose than plain js, and its event-handling is great.

something like $("#wrapperel").on("click",".painbutton",cbfunction),is way more code in plain js.

Re: jQuery 3.0 Released

#30
Whenever a new version of jQuery (or Zepto) comes along, I wonder what would have happened if web development borrowed a page from other ecosystems and browser runtimes had subsumed the jQuery API, shipping it natively.

It'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.

Post reply on HN