Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why apps built with Angular2 are so heavy?

Tags:

angular

Recently we planned to revamp our existing web-app which is built in JMVC. And we decided to go with Angular-2.

And to test what will be the load size, I did the following:

ng new test123
cd test123
ng build -prod

And deployed dist folder content on apache and it showed 1.0MB transferred.

My entire JMVC application, with all the business logic is hardly 1.2MB when loaded in browser.

What can I do to decrease the size of Angular-2 app after deployment?

enter image description here

like image 565
Gan Avatar asked Jun 11 '16 04:06

Gan


People also ask

Why is my angular app so slow?

If you've done your research and figured out that your app doesn't render that much and doesn't render that often, then your code may just simply be quite slow. This is probably due to some heavy scripting and not DOM-related. Use WebWorkers. The Angular CLI also provides a command to generate a WebWorker in a snap.

Is Google still using angular?

Angular is used in public-facing applications and sites such as Google Cloud Platform and AdWords, as well as many internal tools.


1 Answers

As per the comments, the ng2 team are working on reducing the size of framework nearing its release.

Prior to this, following typical http conventions for minimising JS size is obviously the main thing, but I've also found that Webpacks optimisations heavily reduce the size of the generated JS substantially.

enter image description here

Thats 313KB for the entire angular2 code base as well as my entire app which includes inline HTML and Styling (I'm not sure what the result would be for a Hello World example though).

The webpack plugins you can use are

webpack.optimize.OccurenceOrderPlugin(true)
webpack.optimize.UglifyJsPlugin()
webpack.optimize.DedupePlugin()

Hope this helps!

like image 55
Ian Belcher Avatar answered Nov 05 '22 11:11

Ian Belcher