1

I have a pretty good idea about loading an external config file for an Angular app, but I have the following question: does the APP_INITIALIZER provided loading function get executed on the client side, after the AppModule had been delivered to the browser, or on the server side, before the delivery happens?

And if it happens on the client side, doesn't this entail an extra HTTP call to the config file before the application actually starts?

4
  • Thank you, that's what I thought. How mundane (or negligible) would you say the extra HTTP call to my JSON configuration file would be in your opinion? Commented Nov 20, 2017 at 13:12
  • 1
    That probably depends mostly on the on the network connection delay. I'd try hard to avoid any request, especially if you expect it to run on mobile. But if there are no good alternatives, I'd just use APP_INITIALIZER. Commented Nov 20, 2017 at 13:15
  • I hear you, and yet as you say, I know of no other way to better initialize configuration externally, independently of the building process. Ideally the config files would already reside on the server upon which the build is being deployed. Commented Nov 20, 2017 at 13:17
  • 1
    Then go for it and check the profiling tab in the browser devtools to see the actual delay the request causes for your application and if it matters. Otherwise might just be a case of premature optimization ;-) Commented Nov 20, 2017 at 13:18

1 Answer 1

1

If you are not using server-side rendering everything Angular related is only executed in the browser, except perhaps things that are executed at build time before you deploy your Angular application to the server, but APP_INITIALIZER is executed in the browser.

Sign up to request clarification or add additional context in comments.

Comments

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.