Google suggests to use very important CSS inline in head and other CSS inside <noscript><link rel="stylesheet" href="small.css"></noscript>
.
This raises few questions in my mind:
<noscript></noscript>
, which is for script? Will it work when JavaScript is enabled? Is it browsers compatible? Reference
Based on my reading of the link given in the question:
DOMContentReady
, in my opinion, goes against the point of this optimisation: launching new HTTP requests before the document is completely loaded will potentially slow the rest of the page load. Also, see my next point:The original small.css is loaded after onload of the page.
If I could add my own personal opinion to this piece:
noscript
tags and, as pointed out in the comments, it doesn't pass validation.Take this with a grain of salt, however. I would hesitate to say that Google doesn't know what they're doing.
Edit: note on flash-of-unstyled-content (abbreviated FOUC)
Say you a block of text spanning multiple lines, and includes some text with custom styling, say <span class="my-class">
. Now, say that your CSS will set .my-class { font-weight:bold }
. If that CSS is not part of the inline style sheet, .my-class
will suddenly become bold after the deferred loading has finished. The text block may reflow, and might also change size if it requires an extra line.
So, rather than a flash of totally-unstyled content, you have a flash of partly-styled content.
For this reason you should be careful when considering what CSS is deferred. A safe approach would be to only defer CSS which is used to display content which is itself deferred, for example hidden elements which are displayed after user interaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With