Advantages JQuery versus Javascript

4

First of all, I do not want this question to be answered by opinion and therefore not be considered as such by the moderation of the community.

All of us who have used or used JQuery know that once you make the structure of the library you can program in fewer lines of code than in the normal way.

The jQuery libraries are quite lightweight but I wanted to know if someone can show that it is more or less quick to execute Javascript using the libraries or without using them. Greetings to the whole community.

    
asked by Pablo Pérez-Aradros 10.10.2016 в 00:28
source

1 answer

5

Quick response: the execution of an application using pure JavaScript is always going to be faster than using libraries like jQuery.

Now, do not take it the wrong way, but it seems that your question is based on some wrong ideas:

  • " you can program in less lines of code than in the normal way "
  • " I wanted to know if someone can show that it is more or less quick to execute Javascript using the libraries or without using them "
  

you can program in less lines of code than in the normal way

That the code with jQuery occupies less lines than if you had done it with pure JavaScript does not mean that there are fewer lines of code, you should not forget all the lines of code that the library includes by itself and that they are doing all those operations and lines of code that you are "saving" with jQuery.

In fact, unless you are using all the functions available in the library, using a library you will be processing code that you will not use later. That's why it's just a false idea of saving.

Moreover, you may find that you are doing more operations than you think / expected (especially with old versions of jQuery). This is because jQuery will perform additional operations to ensure that the commands will be compatible with different browsers and platforms (something that may not matter in your particular case, but that does matter to jQuery).

  

I wanted to know if someone can show that it is more or less quick to execute Javascript using the libraries or without using them

You must not forget that a JavaScript library is just that, a library: a set of operations / functions that are used to extend the language (JavaScript) and that do not make sense on their own.

They are basically a "wrap" that is put over JavaScript to complement it, they will make it more nice but not faster. The jQuery code is JavaScript. jQuery is just an interface for functions that the programmer could develop from scratch.

So, would the functions be faster if they were developed by the programmer instead of using jQuery? Maybe yes, or maybe not. That will depend on the skill of the developer (jQuery and other libraries have already been polished and debugged and are known to work and they do it efficiently), but if the pure JavaScript code that was generated was similar to the internal jQuery code , then, the option of pure JavaScript will be the same or faster (at least it would save the expenses related to the calls to functions).

In short (I think I'm taking a lot of detours and I'm not explaining myself well): pure JavaScript would be faster ... but that does not mean that libraries should not be used: they make the work easier and, in many cases, the difference will be so minimal that it will not really matter (unless you need an application where execution time is a critical factor).

    
answered by 10.10.2016 / 04:06
source