On apps with server side rendering and lazily loaded modules, when landing on pages with lazy loaded components, ie. requesting pages with lazy loaded components such as http://localhost:4000/lazy in the universal-starter demo app, the existing renderings are hydrated from state transfer and are not rendered again client side.
style[ng-transition], are removed.The above behavior can be see here. On the right in dev tools is the html markup that is rendered and send from SSR. On the left is the page after all the styles are removed in appInitializerFactory.

Debugger with breakpoint at the place where the styles are removed.

Meanwhile a request is made to fetch the lazy loaded bundle.
AppComponent is initialized and the components are re-rendered.

- [ ] aspnetcore-engine
- [ ] common
- [ ] express-engine
- [ ] hapi-engine
- [x] module-map-ngfactory-loader
Run following steps to get universal-starter demo project up and running.
git clone https://github.com/angular/universal-starter.gitnpm installnpm run build:ssr && npm run serve:ssrNow navigate to http://localhost:4000/lazy.
Open debugger and put a breakpoint in platform-browser.jss appInitializerFactory method where styles are being removed.
Reload the page.
@nguniversal versions
Angular CLI: 7.1.4
Node: 10.15.3
OS: darwin x64
Angular: 7.1.4
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.11.4
@angular-devkit/build-angular 0.11.4
@angular-devkit/build-optimizer 0.11.4
@angular-devkit/build-webpack 0.11.4
@angular-devkit/core 7.1.4
@angular-devkit/schematics 7.1.4
@ngtools/webpack 7.1.4
@schematics/angular 7.1.4
@schematics/update 0.11.4
rxjs 6.3.3
typescript 3.1.6
webpack 4.23.1
Occurs even with initialNavigation: 'enabled'
RouterModule.forRoot([
{ path: '', component: HomeComponent, pathMatch: 'full'},
{ path: 'lazy', loadChildren: './lazy/lazy.module#LazyModule'},
{ path: 'lazy/nested', loadChildren: './lazy/lazy.module#LazyModule'}
], {
initialNavigation: 'enabled',
}),
Possible regression as there exists following closed bug reports (to list a few):
@rohit-nair
Hello, did you find any solution to this issue??
I also have the same issue and can't figure it out..
I am suffering from the same problem...
I have the same problem in various projects.
You can view the bug visiting this website that i built using Angular 7 and Angular Universal.
https://huna.io/
Hi. We have the same problem as well. The first paint doesn't have the styles and then, after a split-second, reloads with the styles properly rendered. We already tried with the initialNavigation: 'enabled' but still the issue persists.
I was guided to use https://github.com/angular/preboot with following hack https://github.com/angular/preboot/issues/75#issuecomment-421266570 which solved my issue although in a hacky way.
Hope this helps.
The first thing that needs to be done is set initialNavigation: 'enabled' in the RouterModule config. Please report back if you see flicker even after adding that.
@vikerman The issue's descriptions says:
Is there anything else we should know?
Occurs even with initialNavigation: 'enabled'
RouterModule.forRoot([
{ path: '', component: HomeComponent, pathMatch: 'full'},
{ path: 'lazy', loadChildren: './lazy/lazy.module#LazyModule'},
{ path: 'lazy/nested', loadChildren: './lazy/lazy.module#LazyModule'}
], {
initialNavigation: 'enabled',
}),
Hi Guys, any update on this? thanks!
Still have this flicker
any update on this?
Hi @vikerman
the thing is i need to use initialNavigation: 'disabled', to generate available routes based on server's response
in App Initializer i have code that "router.resetConfig()" with new routes, that i received from server
and in case initialNavigation: 'disabled' it's flickering
is it possible to manage this?
I try this tutorial project to check for flickering problem. And it exists there. Just go to network tab, Disable cache and use Slow 3G network, navigate to /contact and this problem will occurs.
any updates? The issue hurts a lot...
My competitors, who build projects in PHP outperform me in SEO
Common Google!
This issue still exists. I added initialNavigation: 'enabled', but no use. If I reload / refresh the application, it renders twice. Any update on this?
Most helpful comment
@vikerman The issue's descriptions says: