Is AngularJS faster than jQuery?

EDIT: based on the answer, it seems that AngularJS is not faster than jQuery, since it also uses the jQuery version (jqLite).

A friend told me that jQuery can be slow because it needs to parse the entire HTML page to query each in order to be able to find and manipulate DOM objects. For a large page, this will lead to poor performance.

However, AngularJS can be faster with large HTML pages because it "compiles" HTML and has faster access to DOM objects.

It's true? Could you provide a trusting link confirming this?

If this is not the case, please give me an explanation regarding how jQuery and AngularJS differ in terms of access to DOM objects.

I also used performance tests, and I found only one thing: link .

If Angular is not faster than jQuery, why is the test incorrect?

+5
source share
1 answer

The browser analyzes your DOM every time you load the page, so this is not a skeleton issue. AngularJS is built around jqLite, which is actually a faster version of jQuery, so I don't think how it could be faster ...

Another thing, what operations did they calculate? Angular is a completely different thing than jQuery. Angular is a complex MVVM environment, and jQuery is just a library for simplifying and browser-independent DOM manipulation.

Edit: there must be something to this ... I think it happens that some kind of Angular loop with $apply , called at the end, makes it very fast. Perhaps adding elements to the array is much faster than adding text to a string or adding newly created elements to another element container ... When I moved the $apply function to the angularPush function, it will be the slowest. You can also see a jQuery modification. All this makes the native implementation the fastest ...

Here is a modified experiment: http://jsperf.com/angular-vs-jquery-vs-native/38

+9
source

Source: https://habr.com/ru/post/1206020/


All Articles