Live data from Hacker News

jQuery 3.6.0

blog.jquery.com

71–80 of 292 posts

Re: jQuery 3.6.0

#71
post #48

Earlier quoted context omitted.

Conversely, looking at how you do it through jQuery after seeing how it is in Javascript gives me the same reaction. The fact that jQuery is usually assigned to the dollar sign definitely doesn't help, especially for beginners. The amount of questions I've answered that stemmed from a fundamental misunderstanding of how Javascript works, all because they learned jQuery instead of Javascript, is pretty significant.

I remember when I was in uni that the $() must've had a special meaning or something. I was pretty convinced that the $ was some tough mathematical operator or computer science concept that I didn't yet understand. When I learned that it was simply a function invocation that returned a jQuery object so you could chain it, I was absolutely shocked about the simplicity of that statement. Beginning developers sure like…

There's so much magic in programming that as a beginner, it's hard to know which magic you should dig deeper into, vs which is such a treacherous rabbit hole you're better off cargo culting.

Re: jQuery 3.6.0

#72
post #6

Do people still use jQuery? I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElementById, getElementsByClassName, and getElementsByTagName). This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Also there are browser compatibility issues that jQuery solved but a lot of these are so…

> This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Have you actually compared the two methods in a real website? It's like saying why use Ruby when you can use Java. The Javascript document API is super verbose. No thanks.

I'm still a little bit sad we got fetch as part of javascript when the request module had such a great interface. I still prefer the look of it.

https://www.npmjs.com/package/request

Re: jQuery 3.6.0

#73
post #6

Do people still use jQuery? I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElementById, getElementsByClassName, and getElementsByTagName). This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Also there are browser compatibility issues that jQuery solved but a lot of these are so…

I use it extensively to maintaining our apps ui which has coded with old fashioned Backbone, Underscore and Jquery. our UI is working and we do not see need to re-engineer/refactor it to go to newer frameworks just for the sake of it.

Re: jQuery 3.6.0

#74
post #24
post #14

Earlier quoted context omitted.

Please elaborate about toString() ?

If called on a Function it returns the source of the function, which allows for all sorts of meta programming.

If memory serves, a real world example was Angular doing a toString then injecting dependencies before calling eval on the new code.

To be honest, I don’t know that there’s ever a good reason to use it in production as it almost always involves performance and security problems.

Re: jQuery 3.6.0

#75

Earlier quoted context omitted.

> This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Have you actually compared the two methods in a real website? It's like saying why use Ruby when you can use Java. The Javascript document API is super verbose. No thanks.

You don't have to use all of it though, right? You can choose to only only use the applicable parts: eg: ``` $('.container-element') .addClass('active'); // vs document.querySelectorAll('.my-class-selector') .classList.add('active') ``` I use the native APIs all the time, they are not that complicated or overly verbose. Easily memorized with practice IMHO. Also they are all extremely well documented on MDN.

Your example does not work. querySelectorAll returns array and you can't write `array.classList.add("...")`, because array does not have that property. You need to iterate over that array. And that's exactly why jQuery is so much more convenient over native API: you can just treat collections of elements like an element and jQuery will iterate for you if necessary.

Another jQuery advantage is pseudo-selectors which don't exist in CSS.

There are plenty of convenient one-liners in jQuery which will expand to plenty of lines in native API. That said, with modern API and JS features it's not that bad either.

Re: jQuery 3.6.0

#76
post #22

Earlier quoted context omitted.

I think a lot! For example, the new https://www.whitehouse.gov uses jQuery. When you just want to add a small bit of interaction to a mostly-static site, jQuery can help. There's a current trend to complicate things with a JAM stack that really don't need to be complicated. I've seen people propose something like [NodeJS/Ruby/PHP backend] -> GraphQL API -> React Frontend -> static html Where really they could have ju…

> When you just want to add a small bit of interaction to a mostly-static site Then I'd reach for Alpine. Very lightweight, and I can use the fetch API instead of $.ajax.

or Lit-Element.

Re: jQuery 3.6.0

#77
jQuery is also an amazing educational tool for teaching people to program in steps, learning the native DOM methods and then being introduced to jQuery has been really fun to see light bulbs going off for new students.

Re: jQuery 3.6.0

#78
post #6

Do people still use jQuery? I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElementById, getElementsByClassName, and getElementsByTagName). This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Also there are browser compatibility issues that jQuery solved but a lot of these are so…

You wouldn’t believe in the amount of solid applications using jQuery out there. It’s still widely adopted, specially when you are maintaining legacy applications. While I personally don’t use it in my day job anymore (Mostly React nowadays), I still know a good number of people that use jQuery in my local community. Worth noting: Legacy doesn’t mean bad. Just software that sustained the tough test of time.

Re: jQuery 3.6.0

#79
post #6

Do people still use jQuery? I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElementById, getElementsByClassName, and getElementsByTagName). This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Also there are browser compatibility issues that jQuery solved but a lot of these are so…

jQuery is like WordPress. There may be other more streamlined, purpose-built solutions out there, and they all have their uses, but sometimes ease of setup is the thing you're optimizing for, sexiness be damned.

When you have a vast, mature ecosystem and a decade and a half of community knowledge to draw upon, even the most obscure use cases tend to have a precedent somewhere. Being able to jump right to a StackOverflow answer to exactly what you're trying to do is, in my opinion, a highly underrated feature of legacy web technology.

Re: jQuery 3.6.0

#80
post #6

Do people still use jQuery? I thought the biggest advantage of this library back in the day was css selector access of DOM nodes (back when we only had getElementById, getElementsByClassName, and getElementsByTagName). This has been rolled into the Javascript document api via document.querySelector, and document.querySelectorAll. Also there are browser compatibility issues that jQuery solved but a lot of these are so…

I'm trying to wean off of jQuery to reduce dependencies, but it makes me appreciate jQuery all the more. The native JS API is quite a bit more verbose and cumbersome to use, and my absolute biggest gripe with it is that it doesn't even build on modern JS features. It's not compatible with for...of, map, filter, find, etc, which seems really strange for a relatively recent vanilla JS API.

Ironically, http://youmightnotneedjquery.com/ makes a pretty good case in favour of jQuery.

Post reply on HN