【发布时间】:2015-05-03 00:19:56
【问题描述】:
以下哪项将花费更少的时间被浏览器读取?还有什么我可以做的额外的微优化(当然,除了消除空白)?
选项 1:
ol.red-numbers > li:before { color: #A71930; padding-right: 5px; }
ol.red-numbers > li:nth-of-type(1):before { content: "1"; }
ol.red-numbers > li:nth-of-type(2):before { content: "2"; }
ol.red-numbers > li:nth-of-type(3):before { content: "3"; }
选项 2:
ol.red-numbers > li:nth-of-type(1):before { color: #A71930; padding-right: 5px; content: "1"; }
ol.red-numbers > li:nth-of-type(2):before { color: #A71930; padding-right: 5px; content: "2"; }
ol.red-numbers > li:nth-of-type(3):before { color: #A71930; padding-right: 5px; content: "3"; }
【问题讨论】:
-
“还有我可以做的其他微优化吗?”至少你知道你在做什么,但是……你没有更好的事情要做吗?
-
@BoltClock 一位智者曾经说过,“微优化是最大的好处。”
-
我从未将一个列表项视为另一个列表项的直接子项,如果这是有效标记,我会感到惊讶。
标签: css performance optimization browser