CSS delivery optimization: How to defer css loading?

前端 未结 6 662
不思量自难忘°
不思量自难忘° 2020-11-28 02:24

I am trying to optimize the CSS delivery following the google documentation for developers https://developers.google.com/speed/docs/insights/OptimizeCSSDeli

6条回答
  •  猫巷女王i
    2020-11-28 03:01

    WARNING: body{background-image: url("http://example.com/image.jpg");} in css files will make your css files still render-blocking.

    If you tried all the solutions above and you still get the render-blocking warning from PageSpeed insights then you probably have this style rule in your css files. After hours of tests it turns out that this rule is what making ALL of my css to be flagged as render-blocking resources at PageSpeed insights. I found the same issue has been discussed before.

    I don't know why body{background-image: url(...) do this for all the css files!, although I have different images resources in the file for the buttons, icons, ...etc .

    I fixed this by moving this rule from the .css file and put it in the inline styles. Unfortunately, you will have to break your css plan and put the rule in all of your layouts HTML files instead of being in 1 css file that is imported in all of your HTML layouts, but the 90s and green color in PageSpeed insights deserve it.

提交回复
热议问题