I have developed an application in angular 2 with lite server. As soon as I start lite server, my application works fine and fast but after some time, my application becomes very slow. I would restart lite server (npm start
) to fix this, but I am planning to move my application to production. I want to avoid this frequent restart of lite server. How to improve my app performance?

- 72,308
- 93
- 206
- 262

- 31
- 5
-
1If you want to know about production performance, do a production build and use it with a production server. If performance it is still degrading, please post a new question with more details about your application. – Günter Zöchbauer Jan 25 '17 at 06:04
2 Answers
If you want to test your app in production mode ANGULAR CLI can help you a lot.
It can prepare for you a testing running
ng serve --prod
It will start as production mode in your local machine Instead if you want to put it in production mode you can run
ng build --prod --aot (ahead of time compilation)
this will create a dist folder with your bundle.js and other file that you can update directly in your .WAR exploded

- 1,114
- 1
- 10
- 25
When you deploy your ng2-app, I should use AOT(ahead of time) compile. I guess you are using JIT(just in time) compile.
In angular2 guide page,
With AOT, the browser downloads a pre-compiled version of the application. The browser loads executable code so it can render the application immediately, without waiting to compile the app first.
When you use JIT compile, your browser will download your vendor.js which is defined angular2 compiler and it will compile your app just in time. It will make your site render slow.
I recommend to use AOT compile when you deploy, and use lazy loading for resource size.
If you are curious about ng2 AOT compile, read this guide.
And here is example angular2 app with webpack2 and lazy load.
files bundled with aot is smaller than 500KB.

- 311
- 4
- 8