Does jQuery influence the performance of the application?

7

I personally love and use the jQuery library.

Does this library influence the performance of the application?

    
asked by anonymous 11.03.2015 / 22:44

3 answers

9

Yes.

jQuery is a relatively heavy library. Whenever you use jQuery selectors you will be running many functions that may weigh in application performance.

For example if you want to know id of an element you can do in jQuery $(el).attr('id') but you can get the same using pure JavaScript with el.id , the difference in performance is great: link

Of course it is useful to use jQuery, or MooTools, or another library. But as JavaScript evolves it's easier to do what you need with native code (or CSS) and no performance loss.

    
11.03.2015 / 22:50
6

No doubt influence. It's an extra layer that will perform extra things that are not always necessary if you do it directly in Vanilla JS . p>

In addition to hiding things can help on one side and can complicate on another. It is not always easy to realize the inefficiencies of what you are doing when you use a library. It is true that if the programmer does not understand the inefficiencies of the language, the standard library or even the computer in general, it makes no difference.

The blame can be directly from jQuery, it can be from the programmer using it but it can also be from the plugins to jQuery which are not always well written. But even those who are still will have losses because they are an extra bed.

Some people charge the cost of loading the library as another way to worsen performance. Of course loading in memory and preparing every environment has a cost but this cost they complain about is the download load via internet. This makes sense and can eventually happen and degrade your page load significantly. But if the page uses the technique of loading the minimized file from a CDN that everyone else uses, such as official or Google that many people use, will use the cache and will not have to download.

I'm not saying that this loss would make it unfeasible, of course, if that were the case, many people would commit a very serious error. What I criticize most is when there is abuse. Some people have turned a library into language. Then the person can not do anything else in JS even when clearly JS is better at speed, readability, etc. The problem becomes greater when the programmer uses to type less - and does not make the code more concise, which is a virtue.

But for most tasks this loss does not significantly affect.

Some comparisons .

What do you think is faster? A simple for each or each (see the link code) jQuery that besides for each does a lot of thing?

    
11.03.2015 / 22:50
2

Yes, but in most cases the difference is irrelevant in the final result because JavaScript engines in today's browsers are extremely efficient and jQuery is already optimized.

You'll see a lot of people showing how selectors or native methods of the browser type document.getElementById are incredibly faster than jQuery equivalents (type $('') or $(...).prop('id') ) and true, the wrapper method is much less efficient but you still have to do a lot to reflect negatively on your perceptible performance . Usually performance problems come from bad code and not from the overhead caused by the library being used, an excellent example being this John Resig post that talks about a case where twitter was crashing when the user would scroll on the page, the result of a function that made queries in the DOM with each scroll done (which is very, very bad).

It is not part of your question (it has already been answered in the "Yes", the first word of this answer;)) but I will advise that unless you are making an app that needs a very large level (or other equivalent lib) since it takes away several existing headaches when writing raw javascript (it gives you a simpler API, more readable code, uniform behavior between browsers, etc.) / p>     

22.03.2016 / 18:14