In my angular 2 application . i wanted to reduce the time of page loading . When i load the page for the first-time it takes 13 sec to load . Please help me with suggestions.
-
Do you use the -prod or -aot flags when running/building the application?Eduardo Vargas– Eduardo Vargas2017-06-19 09:34:26 +00:00Commented Jun 19, 2017 at 9:34
-
No . I am using for development mode . not using this flagsSantosh– Santosh2017-06-19 09:37:29 +00:00Commented Jun 19, 2017 at 9:37
-
Minify CSS and JS by using -prod when building.Nguyen Huynh– Nguyen Huynh2017-06-19 09:45:22 +00:00Commented Jun 19, 2017 at 9:45
Add a comment
|
3 Answers
Also apply AOT on top of the Webpack it will make drastic change in performance.
Follow below instructions it may be help to you.
- Build the application in production mode
- Bundle the Js and CSS file
- Load images with SubDomain
- Implement lazy loading where possible
1 Comment
Santosh
lazy loading need to be implemented
Upgrade to Angular 4. It is much faster
2 Comments
Santosh
how to convert web-pack to angular 4?
KrystianC
angular 4 is based on webpack. So just do normal upgrade to latest version npm update --save --save-dev. Yuo can install npm-check and it will upgrade all dependencies in more user friendly way if you wish Just remember that you need to have versions specified in package.json files check if you have ^ or * in front of the versions. Or simply overwrite it manually like "@angular/core": "^4.2.2"
What is recommended is that when developing you don`t need to use the prod and aot flags because the compile time is way longer but when building the application for production try using
ng build -aot -prod
it should make it a lot faster. Be aware that some errors may occur in this mode so make to sure to test your workflows before deploying.
4 Comments
Santosh
ng doesn't recognized as a command as i am using web pack .(Not using CLI)
Joe Clay
Should be
--prod, not -prod. Also, you don't need --aot if you're passing --prod - the latter will turn on AOT as well.Santosh
No i am doing it in development mode
Eduardo Vargas
Try following this guide then angular.io/guide/deployment#webpack-and-aot