1

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.

3
  • Do you use the -prod or -aot flags when running/building the application? Commented Jun 19, 2017 at 9:34
  • No . I am using for development mode . not using this flags Commented Jun 19, 2017 at 9:37
  • Minify CSS and JS by using -prod when building. Commented Jun 19, 2017 at 9:45

3 Answers 3

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

lazy loading need to be implemented
0

Upgrade to Angular 4. It is much faster

2 Comments

how to convert web-pack to angular 4?
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"
0

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

ng doesn't recognized as a command as i am using web pack .(Not using CLI)
Should be --prod, not -prod. Also, you don't need --aot if you're passing --prod - the latter will turn on AOT as well.
No i am doing it in development mode
Try following this guide then angular.io/guide/deployment#webpack-and-aot

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.