Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is AngularJS faster than jQuery? [closed]

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

A friend told me that jQuery can be slow because it needs to parse the entire HTML page for each request to be able to find the DOM objects and manipulate them. For a big page, it would get a bad performance.

However, AngularJS could be faster with big HTML pages because it "compiles" the HTML and has a faster access to DOM objects.

Is it true? Could you please give a trustful link that confirms that?

If this not true, please, give me an explanation regarding how jQuery and AngularJS are different regarding accessing DOM objects.

I've also seached by performance benchmarks and I've only found this one: link.

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

like image 423
Ricardo Avatar asked Dec 25 '22 02:12

Ricardo


1 Answers

The browser parses your DOM every time you load the page, so it's not a framework issue. AngularJS is build around jqLite, which is in fact a ligher version of jQuery, so I don't think how it could be faster...

Another thing is what operations did they counted? Angular is a totally different thing than jQuery. Angular is a complex MVVM framework, while jQuery is just a library for easier and browser independent DOM manipulation.

Edit: There must be something to it... I think what happens is that somehow angular cycle with $apply called at the end makes it very fast. Maybe adding elements to an array is much faster then adding text to string or adding newly created elements to another element container... When I've moved $apply function to angularPush function it's the slowest one. You can also look at the jQuery modification. It all makes the native implementation the fastest...

Here is the changed experiment: http://jsperf.com/angular-vs-jquery-vs-native/38

like image 176
Bartek Andrzejczak Avatar answered Dec 28 '22 08:12

Bartek Andrzejczak