Javascript vs jquery

var $ = document.querySelectorAll;
Now you can select element like in jQuery.

The problem I have with jQuery is that it makes beginners use technology that they don’t know how it works behind.

If you want to grow in a great developer and maybe some day build your own framework or library you need to know how DOM, HTTP Requests, effects and other things really works.

1 Like

I will try not to be too redundant, but as others have said, jQuery is just a library with a lot of pre-built javascript functions for manipulating the DOM more easily. In the past, jQuery made it much faster and easier to make things happen on your webpage, make it talk to a server (AJAX), and it helped equalize a lot of code to work in different browsers. All of that could be written in normal, “vanilla” JS, but jQuery simplified it for you. To get the gist, I suggest Code School’s free http://try.jquery.com/ course. You’ll get the idea very quickly. Compare it to the “You Might Not Need jQuery” resources as well. http://javascript30.com has 30 free courses doing DOM-related JS with vanilla JS.

Why is jQuery becoming less popular?

  • Browsers have mostly moved past their previous big inconsistencies.
  • You might find jQuery is a big file to add to your website if you just need to do thing.
  • For small sites, jQuery is fine, but for bigger, more complicated apps, where you will be writing a lot of code, it lacks a guiding structure. This could result in “spaghetti code”. The prevailing practice of the day is to build your web app with smaller, self-contained components rather than one monolithic wall of code.
  • Along with components, newer frameworks (React, Vue) are pushing “reactive” models of app design, where the framework updates your DOM automatically if the data changes. While you could build your own reactive system using jQuery, people tend to use it for “event-driven/imperative” design: i.e. “when the user clicks this, app do this.” Reactive design encourages programmers to write “declaratively,” i.e. “the data should display this way; the user clicks this, and the data updates.” The former (imperative), requires the code to think of all the possibilities, and results in more code. Declarative programming tends to result in simpler, cleaner code.

I think the important part of your JavaScript education is–whether with vanilla JS or jQuery–you learn the basics of the DOM and how JS affects it.

2 Likes

When I started out I was also not a fan of jQuery. I felt it distracted from learning JavaScript more in depth. The dislike faded as I got used to it. It’s still not my primary go to for most solutions, but I don’t avoid it like I used to.

As others have mentioned learning how to do things in pure JavaScript over using jQuery is important for learning how JavaScript works. Also jQuery is becoming less essential than it used to be. That being said it important to know how to use jQuery as well as you will run into situations where you’re searching for how to do something and the first 10+ valid search results will all be jQuery solutions.

As to valid reasons one might dislike jQuery, it’s slow. For most uses this slowness is a non-issue, but once your app becomes more complicated and performance becomes an issue, jQuery may be part of the problem.

On a side note if you just want the selection engine features of jQuery (ie you won’t be using any jQuery plugins) another option is D3. The newest version of D3 is modular and you use only the parts you need while not having to include the full library. I do a lot of data visualization so I’m already using D3 is most projects, and I usually don’t need to bring in jQuery on top of it.
(As to performance I do not know how D3 compares to jQuery or pure JavaScript selections.)

1 Like

Hi Champ,

I guess the whole thing is perspective.

There will never be a lightbulb moment (an ah-ha I get it moment, with this discipline.

Its more like a dimmers witch (gradually over time you’ll be able to see and understand more and more).

Just keep slowly coming back, and hitting it again and again, over and over… go to multiple sources also… many books and many videos.

Remember… its yours if you want it.

1 Like

Hello,

Personally, I prefer vanilla Javascript. I just find it more explicit, and the extra code length doesn’t bother me. Having said that, if you plan on working with professional front-end code, or even just older open-source projects, knowing a bit of jQuery is a must. It’s just a matter of convention.

Most older projects and experienced developers will use it, and you shouldn’t break from their convention based solely on preference. Overall I would say it’s very much worth learning both. :slight_smile:

1 Like

You can also refer to this very similar discussion/question: JQuery vs Javascript