TruthSeeker TruthSeeker - 6 months ago 23
AngularJS Question

Does not Angular 2's reliance on so many javascript file hamper/affect its performance?

I have worked with Angular 1.x and now starting with Angular 2. Now I am overwhelmed to see the number of js scripts that we have to add to our index.html just to get started.

I mean even if I exclude angular's (and its components') own js files, there are

"systemjs"
,
"es6-shim"
,
"reflect-metadata"
,
"rxjs"
,
"zone.js"
.

And I keep on hearing that Angular 2 is 2 to 3 times faster than Angular 1.

I have used AngularJS 1.x and also ReactJS and no where I have seen this much dependency on other scripts.

What I don't understand is this - Doesn't all these script files make the browsers slow? Doesn't they create extra load on the JS Engine of the browser?

And are we assuming that we are only targeting the latest of browsers when we are developing in angular 2 ?

Will anyone please explain?




EDIT:

I would like to understand the performance effect by lots of JavaScript files.

Can you refuse/reject the fact that Angular 2 needs a lot more JS files to start working than Angular 1?

Answer

Well having more file to load may increase the first time loading the page, and memory consumption at start (not necesseraly in then end) obviously.

But once you passed that, this is pretty much unrelated to performance.

Furthermore by using libraries that have been specially developped and optimized for their purpose, angular developers don't have to rewrite their own part of code which would probably less optimized/ morebuggy than existing and widely used ones.

Let's take a simple example : underscorejs or lodash. By including it to your browser you will probably add some time loading, but by using the functionnality that the provide, your code will be probably faster because there is a lot of trick about javascript & performance when it comes to what those libraries are used for.

And it's not because you load those libraries that you will get their full code executed on each javascript loops, same goes for angularJS2 and all his libraries.

The most annoying thing about this could be the need, not only to learn angularJS2, but some of the others components to get things rights about how to code properly with angularJS2, increasing the learning curve so.

Among the file you showed : es6-shim is to make angularJS2 compatible for no-es6 browser, you had the same when using angularJS 1.x on IE8, nothing new for this one.

Comments