Live data from Hacker News

jQuery 3.0 Released

jquery.com

91–100 of 164 posts

Re: jQuery 3.0 Released

#91
post #77

I would suggest the release notes are a better link target: http://blog.jquery.com/2016/06/09/jquery-3-0-final-released/ Developers can figure out how to download it if they are interested.

That was submitted yesterday and flagged as a dupe. https://news.ycombinator.com/item?id=11871658

Re: jQuery 3.0 Released

#93

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

I started using "vanilla" js, then created a method as a name for the huge `[].prototype.slice.call(document.querySelectorAll(selector))` Then as I continued adding useful methods such as ajax() (no, in vanilla js it's not "solved") and turning events off (also non-trivial) I ended up with a jquery alternative: > http://umbrellajs.com/ It's not exactly the same, but most methods are the same or highly compatible. For…

> useful methods such as ajax() (no, in vanilla js it's not "solved")

Right - I use jQuery because I've greater confidence that `.ajax()` will behave correctly across a wide range of browser versions, though I don't have any good evidence about using that vs vanilla `XMLHttpRequest` these days. I'd be interested to know which bits of "not solved" - which aspects in particular are not yet well supported?

Re: jQuery 3.0 Released

#94

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

Last big UX project I did (a GA admin console) used "Valilla JS". It was my first such project (not sure if it would be appropriate to call stuff done in early 2000s Vanilla JS). But in another recent refactoring I had to replace an ancient (IE5) datepicker and was dismayed to find there was not broad support for input type=date so I used one of the quality JQuery UI datepickers.

Re: jQuery 3.0 Released

#95

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) => { / *…

The way I handle situations like this is to only put the catches where I need them to serve some purpose. Generally, I don't catch errors at the start of the chain because I can't know what to do with them at that point. If I do catch them, it's only for logging or similar purposes and I still let the error propagate further.

One pattern I use is to rethrow the error:

return service.fetchData().then((data) => {}).catch((err) => {console.log(err); throw err;});

Another pattern I use is to split the promise chain so that I let my main results flow be the result that gets passed on, but I can do other things in a parallel manner internally:

let results = service.fetchData().then((data) => {}); results.catch((err) => {console.log(err);}); return results;

Re: jQuery 3.0 Released

#96
post #3

http://youmightnotneedjquery.com/

A good example of why I will continue using jQuery for the time being.

Yes, but it's always good for us to remember that everything has a cost, and so does jQuery (memory footprint/new dependency/complexity). It's a conscious decision we should make on every project, and yes in most cases it would take 0.5s to make a decision in jQuery's favor. We should do so anyways, since it's good practice. Taking into account the presumed state of Moore's Law and all.

Re: jQuery 3.0 Released

#97
post #32
post #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 an…

Well it's 2016 and we still don't have nodeList.forEach() so it can't be much worse.

Actually, we do, since Chromium 51. See https://dev.opera.com/blog/opera-38/

Re: jQuery 3.0 Released

#98
post #95

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) => { / *…

The way I handle situations like this is to only put the catches where I need them to serve some purpose. Generally, I don't catch errors at the start of the chain because I can't know what to do with them at that point. If I do catch them, it's only for logging or similar purposes and I still let the error propagate further. One pattern I use is to rethrow the error: return service.fetchData().then((data) => {}).cat…

> return service.fetchData().then((data) => {}).catch((err) => {console.log(err); throw err;});

Yes - but this kind of code requires that you know that something else chains the promise and handles 'err' - which is my entire complaint, a higher level function shouldn't need to know whether it has children or if they do error handling. Otherwise it's back to the same kind of callback style where you have to go into another file and modify a top-level function to accommodate adding a child.

Edit:

I would rather you and the other commentators here re-read my parent post, as well as the relevant resources[0][1][2] - I seriously think I'm repeating the same thing for the 4th time here, no - I don't need an explanation of how promises work; I only was pointing out that the previous (2.0) dferred.promise model actually fits most better in most of use cases that I've experienced than the es6 one and I found that quite curious; but it seems impossible to have that discussion without being on the same page first.

[0] https://blog.jquery.com/2016/06/09/jquery-3-0-final-released...

[1] https://api.jquery.com/deferred.promise/

[2] https://developer.mozilla.org/en/docs/Web/JavaScript/Referen...

Re: jQuery 3.0 Released

#99
post #76
post #3

http://youmightnotneedjquery.com/

That page does an excellent job of convincing me to carry on using jQuery. if (el.classList) el.classList.contains(className); else new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className); vs $(el).hasClass(className);

I don't think anyone would suggest you write all of the first codeblock every time you want to check a class. You'd put it in a function and call that, much like jquery does.

The point is that this site explains how you do it because a) that's probably easier than trawling through the jquery source b) including this polyfill when you know you need it might save you from requiring all the rest of jquery.

Re: jQuery 3.0 Released

#100

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) => { / *…

If you're not handling the error in the first promise, then throw it again.
Post reply on HN