Optimize css vs Google page speed is messing with me

↘锁芯ラ 提交于 2019-12-12 01:34:34

问题


I'm using google page speed and it's telling me my css is inefficient...

Very inefficient rules (good to fix on any page):

* table.fancy thead td    Tag key with 2 descendant selectors and Class overly qualified with tag
* table.fancy tfoot td    Tag key with 2 descendant selectors and Class overly qualified with tag

The css rules are

table.fancy {border: 1px solid white; padding:5px}
table.fancy td {background:#656165}
table.fancy thead td, table.fancy tfoot td {background:#767276}

I want the header and footer in a different background color than the body of the table (a data table)

  • On what grounds this is inefficient?
  • How to make it more efficient?

I will not add a class to the thead and tfoot for googles's sake.


回答1:


Google's page speed says that specifying 2 descendants is inefficient, which may be true, but I doubt it'll make any difference on the end-user's experience. On the other hand, sometimes you have to use this way to do what you want. Other times, it's a matter of making the CSS easier to read and maintain.

Ultimately it's your CSS, so do what you want. I don't think that micro-optimization will matter.

See also: this question



来源:https://stackoverflow.com/questions/2612555/optimize-css-vs-google-page-speed-is-messing-with-me

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!