Live data from Hacker News

jQuery 3.6.0

blog.jquery.com

51–60 of 292 posts

Re: jQuery 3.6.0

#51
post #22
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 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.

Re: jQuery 3.6.0

#52
post #40

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.

How so? Who stops you from doing something like `const $ = document.querySelector`?

Good point

Re: jQuery 3.6.0

#53
post #22
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 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…

I do think in some cases SPA make sense, but in many other cases just using a bit of jQuery/vanilla js to add a bit of interaction is enough. Server side rendering is way easier to do and is often faster to load for the client.

Re: jQuery 3.6.0

#54
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 never understood why people say “We’ve solved your jQuery problem” by introducing getElementsByClassName() or even querySelector(). When I come back to my older app, $(“.my-class”) is still much nicer. jQuery gets out of the way, the class gets syntax-highlighted, and .focus() can’t create an NPE.

I know it doesn't replace jQuery, but this is fairly straightforward:

  $ = document.querySelector.bind(document)
  $$ = document.querySelectorAll.bind(document)

Re: jQuery 3.6.0

#55
post #40

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.

How so? Who stops you from doing something like `const $ = document.querySelector`?

There's a ton of other functions you need like element.addEventListener, insertAdjacentElement, XMLHttpRequest (when you need progress) etc. etc. At that point you might as well save yourself and the person after you a major headache and just use jQuery whose API everybody knows.

Re: jQuery 3.6.0

#56

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.

[deleted]

Re: jQuery 3.6.0

#57
post #14

jQuery taught me how to write JavaScript frameworks. John Resig, the founder of jQuery, wrote a book called "Secrets of the JavaScript Ninja" was back then really a mindbender. Function.prototype.toString() is really the craziest thing I know to date regarding JS. Heavily used in earlier versions of jQuery according to the book.

Please elaborate about toString() ?

The toString() method returns a string representing the source code of the function.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: jQuery 3.6.0

#58
post #48

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.

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 to project their cognitive insecurities onto programming. Or at least, I did :)

Re: jQuery 3.6.0

#59
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…

Yep. I still use it for side one-off projects here and there. For me, there's just something so convenient about being able to make a html page that you can drop in a quick CDN link for jquery and not have to worry about compiling, webpack, create-react-app etc. I'll still use React when something is a larger project with a ton of moving parts, but otherwise I stick with jquery. As for why I'm not using the native DO…

I hear you. Personally I think learning the native APIs isn't so bad once you take the plunge. They are easily memorized with practice. Imagine not needing to go for that CDN link (or depending on some 3p for your website to work correctly)

Re: jQuery 3.6.0

#60

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.

Technically that breaks, you want:

    document.querySelectorAll('.my-class-selector').forEach(el => el.classList.add('active'))
Personally I use the native APIs because they aren't that hard to use (most of them, anyways) and I tend to be OCD about bundle sizes, but to each their own, I suppose.
Post reply on HN