影响 reflow 的因素及其优化
2010-10-19 21:38
302 查看
Yahoo! 性能工程师 Nicole Sullivan
在最新的文章 《Reflows & Repaints: CSS Performance making your JavaScript slow?》
中总结了导致 reflow 发生的一些因素:
调整窗口大小(Resizing the window)
改变字体(Changing the font)
增加或者移除样式表(Adding or removing a stylesheet)
内容变化,比如用户在input框中输入文字(Content changes, such as a user typing text in
an input box)
激活 CSS 伪类,比如 :hover (IE 中为兄弟结点伪类的激活)(Activation of CSS pseudo
classes such as :hover (in IE the activation of the pseudo class of a
sibling))
操作 class 属性(Manipulating the class attribute)
脚本操作 DOM(A script manipulating the DOM)
计算 offsetWidth 和 offsetHeight 属性(Calculating offsetWidth and offsetHeight)
设置 style 属性的值 (Setting a property of the style attribute)
reflow
会引起开销,影响页面的性能,那如何才能做到合理的优化呢?Nicole Sullivan
也提供了部分建议:
如果想设定元素的样式,通过改变元素的 class 名 (尽可能在 DOM 树的最里层)(Change classes on the
element you wish to style (as low in the dom tree as possible))
避免设置多项内联样式(Avoid setting multiple inline styles)
应用元素的动画,使用 position 属性的 fixed 值或 absolute 值(Apply animations to elements that are position fixed or absolute)
权衡平滑和速度(Trade smoothness for speed)
避免使用 table 布局(Avoid tables for layout)
避免使用CSS的 JavaScript 表达式 (仅 IE 浏览器)(Avoid JavaScript expressions in the CSS (IE only))
中文:http://www.planabc.net/2009/04/13/reflow/
原文: http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/#expressions
在最新的文章 《Reflows & Repaints: CSS Performance making your JavaScript slow?》
中总结了导致 reflow 发生的一些因素:
调整窗口大小(Resizing the window)
改变字体(Changing the font)
增加或者移除样式表(Adding or removing a stylesheet)
内容变化,比如用户在input框中输入文字(Content changes, such as a user typing text in
an input box)
激活 CSS 伪类,比如 :hover (IE 中为兄弟结点伪类的激活)(Activation of CSS pseudo
classes such as :hover (in IE the activation of the pseudo class of a
sibling))
操作 class 属性(Manipulating the class attribute)
脚本操作 DOM(A script manipulating the DOM)
计算 offsetWidth 和 offsetHeight 属性(Calculating offsetWidth and offsetHeight)
设置 style 属性的值 (Setting a property of the style attribute)
reflow
会引起开销,影响页面的性能,那如何才能做到合理的优化呢?Nicole Sullivan
也提供了部分建议:
如果想设定元素的样式,通过改变元素的 class 名 (尽可能在 DOM 树的最里层)(Change classes on the
element you wish to style (as low in the dom tree as possible))
避免设置多项内联样式(Avoid setting multiple inline styles)
应用元素的动画,使用 position 属性的 fixed 值或 absolute 值(Apply animations to elements that are position fixed or absolute)
权衡平滑和速度(Trade smoothness for speed)
避免使用 table 布局(Avoid tables for layout)
避免使用CSS的 JavaScript 表达式 (仅 IE 浏览器)(Avoid JavaScript expressions in the CSS (IE only))
中文:http://www.planabc.net/2009/04/13/reflow/
原文: http://www.stubbornella.org/content/2009/03/27/reflows-repaints-css-performance-making-your-javascript-slow/#expressions
相关文章推荐
- 【DSP开发技术】影响高性能DSP功耗的因素及其优化方法
- MySQL影响性能的因素原因以及性能优化配置详解
- 淘宝店铺优化中影响商品排名的几个必看因素
- 网站优化之影响网站打开速度的五大因素
- [转]影响搜索引擎优化的八项因素
- 盘点2014年网站优化过程中影响蜘蛛抓取的因素
- 排名前10位的网站优化因素的影响有机搜索引擎的流量
- Google排名优化的几个影响因素
- \t\tSQL Server 索引结构及其使用 查询优化/高效分页的最关键因素:聚集索引
- 影响网页加载速度的因素有哪些及优化方案
- 50个影响网站优化的因素
- google优化之空间因素的影响
- SEO之:影响百度网页快照优化排名的因素
- reflow(回流)和repaint(重绘)及其优化
- web设计中那些因素可能影响网站后期优化
- mysql优化之影响mysql性能因素一
- MySQL数据库的性能的影响分析及其优化
- 网络银行的基本概念,论述了影响网络银行安全的因素及其安全防范策略
- 网站性能的影响因素与优化方法(阅读笔记)
- 淘宝针对买家购买优化中需要考虑到的影响销量的各类因素