【问题标题】:Optimize css vs Google page speed is messing with me优化 css vs Google 页面速度让我很困惑
【发布时间】:2011-02-06 10:33:58
【问题描述】:

我正在使用谷歌页面速度,它告诉我我的 css 效率低下...

非常低效的规则(适用于任何页面):

* 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

css规则是

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

我希望页眉和页脚的背景颜色与表格主体(数据表格)不同

  • 这效率低下的理由是什么?
  • 如何提高效率?

为了 google 的缘故,我不会给 thead 和 tfoot 添加一个类。

【问题讨论】:

    标签: optimization performance css-selectors micro-optimization


    【解决方案1】:

    Google 的页面速度表明指定 2 个后代效率低下,这可能是真的,但我怀疑这会对最终用户的体验产生任何影响。另一方面,有时您必须使用这种方式来做您想做的事情。其他时候,问题在于使 CSS 更易于阅读和维护。

    归根结底,这就是你的 CSS,所以做你想做的事。我认为微优化并不重要。

    另请参阅:this question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-28
      • 1970-01-01
      • 2017-05-18
      • 2015-06-07
      • 2013-06-01
      相关资源
      最近更新 更多