Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question

closed as too broad by Mureinik, Daedalus, gdoron, James A Mohler, charlietfl Nov 1 '14 at 20:05

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs. If this question can be reworded to fit the rules in the help center, please edit the question.

    
It's true that AngularJS uses jQuery internally... –  gdoron Nov 1 '14 at 19:48
    
I don't think this is true. How can anything "compile" an html page? AngularJS is still written in JavaScript. If anything, I would say Angular would be slower than jQuery because it has to watch the scope for changes, which is expensive if you have a large scope. –  soktinpk Nov 1 '14 at 19:48
    
@soktinpk, it's not slower, it does other things. Are airplanes faster than fridges? –  gdoron Nov 1 '14 at 19:50
    
If it is the same, I would like to understand the image above. –  Ricardo Nov 1 '14 at 19:50
2  
@Ricardo, I didn't read you jsperf only the result. If native js is slower than a framework (like in your comparison) then it was done wrongly 100%. –  gdoron Nov 1 '14 at 19:53

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
    
The link explains how the test was done: rendering a list populated from an array. –  Ricardo Nov 1 '14 at 19:52
1  
Right, because DOM manipulations are slow. I bet if you kept the string in a temporary array/string and changed the DOM once at the end in jQuery, it would also be very fast. –  soktinpk Nov 1 '14 at 21:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.