Javascript vs jquery

Seeing how you are a beginner, I think you would be better off focusing on building websites with jQuery than diving into the argument. jQuery simplifies things for beginners, and I think your main priority as a new learner should be to build websites, not dive into controversies. So for now, my advice is use it. Build websites with it. As you progress, you will learn more, and then you can dive in and make your own conclusions. For now, I think your focus should be on what can I make - not what is the absolute best way to make something with what disadvantages compared to the advantages of X framework… No. Just build, have fun, and learn - that’s what is important, not what tools you are using.

2 Likes

I’m a bit sceptical about the benefits of learning “native” js ways to manipulate the DOM. Sure, you definitely need to learn JavaScript as a language, learn how to write algorithms in it, and learn its features and quirks as compared to other languages. And maybe in your future job you’ll never write a single line of jQuery… but you’ll be doing very little native DOM manipulation either, because it will mostly be handled by the framework or library your project uses.

jQuery is a good starting point because it’s simple and cross-browser compatible, so you can use it to quickly build simple websites while you’re learning. And there’s a good chance you’ll get to use it professionally too - it’s still a very widely used library.

3 Likes

I don’t get the “hate” jQuery has been receiving recently. As if it’s the current hipster thing to do, hate on jQuery for nothing but it’s large library size.

Then same people will be using Bootstrap and it’s advance features,… which is dependent on jquery lib being loaded.

So now we’re back again to native DOM manipulation and writing conditionals for different browsers?

1 Like

what “hate” are you talking about @owel

1 Like

Hi! To write a pure JavaScript is very important for learning the language and understanding what exactly happens with your code. There is no rules where to use JavaScript or where to use jQuery, because they are absolutely interchangeable and it all depends on your desire. Look this great site: http://youmightnotneedjquery.com.

But jQuery has several remarkable features on my mind:

  1. The purpose of jQuery is to make it much easier to use JavaScript on your website, so jQuery simplifies a lot of the complicated things from JavaScript, like AJAX calls and DOM manipulation.

  2. The jQuery team knows all about cross-browser issues, and they have written this knowledge into the jQuery library. jQuery will run exactly the same in all major browsers, including Internet Explorer 6!

3 Likes

I’ve run into all sorts of articles, blog posts, forum answers on this.
Try googling jquery sucks, jquery is bad, don’t use jquery, etc

1 Like

@owel Ah. So, most of those arguments have to do with relying on the jQuery library instead of using native JavaScript. Which I can understand to a certain degree, but that argument is no different than the argument for/against using any other JS library (e.g., lodash). In that regard it may as well be pointed out that people using reset.css would be better served by not using reset.css and instead hardcoding what it does into their css library … which isn’t an invalid argument, but illustrates how arbitrary these distinctions can be.

2 Likes

For example, Twitter Bootstrap use jQuery. If jQuery is bad, don’t use Bootstrap either. Yes, it is possible, but do you realize how much code you should wright to do simple things?

Exactly my point. See my post further above.

1 Like

Oh, agreed; I was merely trying to accentuate it, not disagree with you

1 Like

Thanks @IsaacAbrahamson for the advice.

Thanks @KeJSaR for this link

First thing first Javascript is a programming language and Jquery is a Javascript library.
That means Jquery is a set of functions written in Javascript to easy up things. So wen you use Jquery you
instantly use javascript . Let me clear things up with some examples:

/* Select something from the DOM: */
    // jQuery
    $('selector');
    
    // Native Javascript
    document.querySelectorAll('selector');

/*Wrap an HTML structure around each element:  */

// jQuery
$('.inner').wrap('<div class="wrapper"></div>');

// Native
Array.prototype.forEach.call(document.querySelectorAll('.inner'), (el) => {
  const wrapper = document.createElement('div');
  wrapper.className = 'wrapper';
  el.parentNode.insertBefore(wrapper, el);
  el.parentNode.removeChild(el);
  wrapper.appendChild(el);
});

So, as you can see Jquery needs less writing wen doing complex things but Jquery is a pretty large file and needs to be parsed.
I recommend to use Jquery only wen doing very complex things, if you only need to add some click events on some elements it’s pretty easy to use pure JavaScript.

1 Like

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