slixurd
2014-03-11 12:43:10 +08:00
一拖出去搜 #footer > h3 low performance就搜到google develops的文章了
而且也有解释,实际上就是后代选择器,子元素/兄弟选择器效率低而已
Descendant selectors are inefficient because, for each element that matches the key, the browser must also traverse up the DOM tree, evaluating every ancestor element until it finds a match or reaches the root element. The less specific the key, the greater the number of nodes that need to be evaluated.
Child and adjacent selectors are inefficient because, for each matching element, the browser has to evaluate another node. It becomes doubly expensive for each child selector in the rule. Again, the less specific the key, the greater the number of nodes that need to be evaluated. However, while inefficient, they are still preferable to descendant selectors in terms of performance.