-
Notifications
You must be signed in to change notification settings - Fork 481
InlineCritical CSS optimization not working in Angular Universal App using Bootstrap styles #2002
Comments
A potentiation problem that I spotted is that it appears that you are only enabling critical css inling on your browser build. To enable critical css inlining during server side rendering you can change the engine initialization to // Our Universal express-engine (found @ https://github.com/angular/universal/tree/master/modules/express-engine)
server.engine('html', ngExpressEngine({
bootstrap: AppServerModule,
+ inlineCriticalCss: true,
})); If the above doesn't solve the issue, I'll look more into this in the coming days. |
Thank you Alan, I was not aware of that property in the server initialization. I added it to the test app and there is no more style blinking, but when I tested it in my real project, I realized that another problem has arised with local fonts (another blinking issue). I updated the test app, adding a custom WOFF2 font file and preloading it in the index file. I also added a title in appComponent.html that uses this font-family. Without inlineCritical optimization, you should see no blinking, but with the optimization enabled (both in browser and server) the font is not preloaded. Is there any solution to this kind of behavior? |
@jcrespoven, thanks for getting back. With regards to the fonts I think I might now what it is happening. Likely this is something that we’ll need to fix. Let me get back to you on this in the coming days. Thanks. |
I have a fix for the mentioned issue #2004. However, for this to work, you do need to defined at least one critical css rule that uses the font ie |
…hen using crittical css inlining When critical font rules are not inlined it will cause blinking as during first render the fallback font will be rendered. Related to angular/universal#2002
…hen using crittical css inlining When critical font rules are not inlined it will cause blinking as during first render the fallback font will be rendered. Related to angular/universal#2002 (cherry picked from commit 11b1d9c)
…critical css inlining When critical font rules are not inlined it will cause blinking as during first render the fallback font will be rendered. Closes #2002
Thank you Alan, that was fast! Is going to be absolutely neccessary to define a css rule that uses the font in styles.scss, or is this a temporary fix? |
If this is fixed upstream in https://github.com/GoogleChromeLabs/critters it would no longer be needed. |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
🐞 Bug report
What modules are related to this issue?
Is this a regression?
No
Description
InlineCritical optimization is not working as expected in Angular Universal applications that are using Bootstrap styles. A blink of unstyled html is shown. It seems that bootstrap styles are not inlined as critical and are being lazy loaded.
🔬 Minimal Reproduction
I have created a reproduction app where you can check the issue: test-app
It's a new application, with Angular Universal and Bootstrap dependencies added, and InlineCritical optimization enabled. I moved the AppComponent styles to the corresponding SCSS file and also added a red square div that should appear centered at the top of the screen.
If the application is served in SSR mode, you should see how the red square blinks when refreshing the page (it has no bootstrap styles until styles.xxxxxxxxx.css is loaded).
🔥 Exception or Error
No errors are shown
🌍 Your Environment
The text was updated successfully, but these errors were encountered: