Optimize CSS Delivery code snippet is bad

Skip to first unread message

Zsolt Kakuk

Aug 23, 2017, 5:24:09 AM8/23/17
to page-speed-service-discuss
Hi All,

I just want to spot out that the code snippet on this url is bad:

It has been out there for so long that I hardly believe that no one ever spot it's not even working in browsers not supporting requestAnimationFrame.
This part fails with uncaught reference error:
var raf = requestAnimationFrame || mozRequestAnimationFrame ||
|| msRequestAnimationFrame;

To make it work well all raf function references should be prefixed by a "window."

It's an other question that I disagree with this rule. Why should I want my CSS to load asynchronously in such a tricky way? Especially if I don't want a FOUC anywhere on the page.
If this was so important for web developers then I suppose an async attribute would have already been introduced to standards like in case of scripts.
I think caching CSS in browser side or in a Service Worker is fully enough.

This script is overkill and ugly and it'd be better to remove from the page speed improvements suggestions.
Of course only in my opinion.


Joshua Marantz

Aug 23, 2017, 8:36:15 AM8/23/17
to zsolt...@catenamedia.com, page-speed-service-discuss
Good catch on the "window.".  Will fix!

The strategy described here is to inline your critical CSS, and delay-load your non-critical CSS.  All other mechanisms we tried for delay-loading seemed to block the browser from rendering until the non-critical CSS was loaded.

Can you describe more about your service-worker strategy?  That sounds like the kind of thing that would be interesting the second time you visit a web site, and this approach is trying to provide a fully rendered page without loading an external resource with a cold browser cache.  But maybe you've got another trick up your sleeve :)

This email and the information it contains is confidential and may be legally privileged and intended solely for the use of the individual or entity to whom it is addressed. If you have received this email in error please notify me immediately. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. You should not copy it for any purpose, or disclose its contents to any other person. Internet communications are not secure and, therefore, Catena Operations Ltd does not accept legal responsibility for the contents of this message as it has been transmitted over a public network. If you suspect the message may have been intercepted or amended please notify me. Finally, the recipient should check this email and any attachments for the presence of viruses. Catena Operations Ltd accepts no liability for any damage caused by any virus transmitted by this email. Thank you.

You received this message because you are subscribed to the Google Groups "page-speed-service-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to page-speed-service-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/page-speed-service-discuss/8f53a447-1af7-4440-9b4d-2f48ceb119a3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
0 new messages