CSS3 - 性能最佳实践是什么?
去年,我花了很长时间阅读 JavaScript 性能、瓶颈和最佳实践。在我的最新项目中,我使用 CSS3 并回退到 javascript/jquery 来实现基本动画和效果(例如悬停),并且有兴趣进一步尝试 CSS3。
CSS3 性能有问题吗?
如果是,最佳实践是什么?
例如,transition: all 150ms ease-out;
是否比 transition: opacity 150ms escape-out, background-color 150ms escape-out;
使用更多内存?
[请不要只回答我的示例问题!]
Last year I spent a long time reading up on javascript performance, bottlenecks and best practices. On my latest project I'm using CSS3 with fallbacks to javascript/jquery for basic animations and effects such as hovers and am interested in experimenting with CSS3 further.
Are there issues with CSS3 performance?
If yes, what are the best practices?
For example does transition: all 150ms ease-out;
use more memory than transition: opacity 150ms ease-out, background-color 150ms ease-out;
?
[please don't just answer my example question!]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
哦,是的!如果您喜欢调整性能 - 您会很高兴知道 CSS3 存在很多性能问题。
position:fixed
粘性页眉/页脚等来绕过此优化 - 效果会很谨慎在不同的浏览器中,Opera 目前似乎受影响最大。inset
框阴影和具有大扩散半径的框阴影可能会导致在任何浏览器中重绘时出现明显的挂起。jQuery.animate
)O yes! If you like to tinker with performance - you will be glad to know there is a LOT of performance issues with CSS3.
position:fixed
sticky headers/footers with and so on - effect will wary in different browsers, Opera seems most affected currently.inset
box shadow, and box-shadows with large spread radius can cause observable hangs on redraw in any browser.jQuery.animate
).为了测试这一点,您必须让动画发生 500 或 1000 次并计时。
Canvas 和 HTML5 动画比 Flash 占用更多的 CPU 资源。 iPhone 上的 Flash 性能优于 HTML5 替代品。为了方便起见,我会使用 JQuery 来制作动画、音频和视频,因为 HTML5 交换了灵活性。
To test that out, you would have to make your animation happen 500 or 1000 times and time it.
Canvas and HTML5 animations way more CPU than flash. Flash on the iPhone outperforms HTML5 alternatives. I would do my animations, audio and video using JQuery as HTML5 swaps flexibility for convenience.