I'm using Angular 5 with angular-cli.
I would like to know how I can execute several http calls before the DOM is 'ready' and the application initialized. I want to know why the application is very big (I am doing lazy loading) and in the network connections I see that I lose time that I can use to make http calls while the DOM is doing its work.
Here we can see it in the chrome developer tools, in the network tab.
I tried to add a provider in the AppComonent like this:
{
provide: APP_INITIALIZER,
useFactory: (setup: SetupService) => () => setup.execute(),
deps: [SetupService],
multi: true
}
And also doing it in the main.ts in this way:
setupSerice.setup().then(() => {
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
});
The setupService is the one that makes the calls http
What else could I try or do?
Thank you very much in advance.