HTML元素:属性排序 [英] HTML element : Attribute ordering
本文介绍了HTML元素:属性排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
- 浏览器性能
- 渲染(显而易见或不可)
- 客户机/服务器计算资源
- 什么?
他们是我应该考虑的排序标准吗?
我只能想
它会影响JQuery选择的第n个属性。 < div class =fooid =bar>< / div>
vs
< div id =barclass =foo>< / div>
解决方案
在查询方面:
- 为选择器O(1)使用ID而不是按类O(n)选择
- 使用类来选择多个元素,只有一个元素的选择的ID(这将导致你只使用一个id或一个类,通常从来都不是)
在渲染方面:
- 最小化浏览器重排( https://developers.google.com/speed/articles/reflow )
- CSS:仅使用一次声明( https://developers.google.com/speed/articles/optimizing-css )
Analyzing several pages and noticing different approaches/writing styles, I am wondering if the order of HTML element attributes effect:
- browser performance
- rendering (noticeable or not)
- client/server computational resources
- anything?
Is their a standard for the ordering that I should consider?
I can only think of it effecting JQuery selections of nth attribute.
ie:
<div class="foo" id="bar"></div>
vs
<div id="bar" class="foo"></div>
解决方案
On the querying side:
- Using IDs for selectors O(1) instead of selecting by class O(n)
- Use classes for selections of multiple elements, IDs for selections with only one element (this will cause you to only use either an id or a class, usually never both)
On the rendering side:
- Minimize browser reflow ( https://developers.google.com/speed/articles/reflow )
- CSS: Use a declaration only once ( https://developers.google.com/speed/articles/optimizing-css )
这篇关于HTML元素:属性排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文