`
zha_zi
  • 浏览: 590291 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

Build smoother web apps with Chrome Developer Tools

 
阅读更多

Whether your web app involves scrolling down a long list of news headlines or a game with flying birds and crumbling structures, you want your web app to look as smooth as native apps. It used to be tricky to chase down the cause of animation jitter and lag in user actions with Chrome Developer Tools. This is why we’ve added the Frame Mode to our Timeline panel to help you pinpoint offending long frames and understand what’s causing them to run slowly.


So, what’s a frame? A frame includes all the tasks that the browser needs to perform in order to update the screen upon a user action or a tick of the animation timer. A complex, but not uncommon, sequence might be:

  1. run JavaScript animations and other event handlers 
  2. update CSS animations 
  3. recalculate styles and lay out the elements in the DOM 
  4. re-paint the updated layers of the page 
  5. compose them and present to the user 
Delivering a butter-smooth animation means completing all of the above in less than 16.6ms(common 60Hz refresh rate). If you are not done by then, you’ll miss the frame and the animation will appear janky.

To see how using Timeline can help you, run your favorite browser-based game, then open Developer Tools and record the Timeline while the game is running some animation. The Timeline Frame mode will now show you colored bars, each representing a frame. The colors correspond to different types of timeline events:
  • network activity and HTML parsing (blue) 
  • running JavaScript (yellow) 
  • performing style recalculation and layout (violet) 
  • painting and compositing (green) 
You can zoom in by selecting several frames or by clicking on a particular frame of interest. Looking at a specific frame in detailed view will show you the frame duration, and you can find more detailed statistics by hovering on it.

 

Even if your web app doesn’t have animation in it, the notion of a frame is still useful because the browser performs a repeated sequence of actions while processing input events such as keypress, mouse actions, scrolling etc. Leaving enough time to process such events inside a frame makes your app more responsive and interactive, resulting in a better overall experience for users.

In large web applications with huge DOM trees, layout typically takes time and resources. Doing it in a loop makes things much worse. So we’ve added a warning mark on layouts that were forced, by requesting positional properties (e.g. offsetWidth and offsetHeight) of DOM elements from JavaScript. If you hover over the layout event, you can see two stacks -- one that invalidated the DOM and another that caused layout synchronously. You can also see the area that had to be re-laid highlighted on the screen.

 

Finally, don’t forget that the best practice for dealing with animations is to use therequestAnimationFrame API, which guarantees that Chromium will call back your animation code in sync with the display refresh.

You can learn more about optimizing rendering performance of a page in Tom Wiltzius’ article on html5rocks.com. Follow Google Chrome Developers on Google+ or @ChromiumDev on Twitter for more news on Chrome Developer Tools.

Posted by Andrey Kosyakov, Software Engineer
分享到:
评论

相关推荐

    kalman_smoother.rar_Kalman smoother_backfitting_kalman_kalman_sm

    this program helps in kalman smoother learning

    Cubature Kalman Smoother (CKS)

    **Cubature Kalman Smoother (CKS)** 是一种高级的滤波和平滑算法,主要用于估计在非线性动态系统中的状态。在信号处理、控制理论和数据融合领域,CKS是一种强大的工具,特别是在处理高维和非线性问题时。与传统的...

    ComponentOne Studio for ASP.NET Wijmo 2012 v3 5/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2012 v3 4/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2012 v3 2/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2012 v3 1/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2012 v3 3/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    OLM Smoother_AE动画插件

    是一款将矢量线转换成平常POTOSHOP里的普通线条的插件不改变像素,达到美化矢量线的作用, 是当下日本动画制作中不可缺少的插件,鉴于我在此网站也找到能给自己工作带来实惠方便的软件,特将次插件放出方便需要的人使用....

    ComponentOne Studio for ASP.NET Wijmo 2013 v1 3/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2013 v1 5/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2013 v1 2/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2013 v1 4/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    ComponentOne Studio for ASP.NET Wijmo 2013 v1 1/5

    Empower your team with the tools they need to build engaging Web applications. ComponentOne provides the ultimate UI controls from WebForms to MVC powered by the core client technology: Wijmo. Learn ...

    Optimal_filtering_with_Kalman_filters_and_smoother

    Optimal_filtering_with_Kalman_filters_and_smoother 本文档总结了Kalman滤波器和平滑器在 Matlab 工具箱 EKF/UKF 中的应用,旨在提供一个关于Kalman滤波器的详细指南。 kalman滤波器的优点 Kalman滤波器是一种...

    Bi-Exponential Edge-Preserving Smoother

    论文 Bi-Exponential Edge-Preserving Smoother 的JAVA实现,可用于保边去噪,人脸磨皮,速度比双边滤波器快。

    Beginning ASP.NET for Visual Studio 2015

    This guide shows you what all the fuss is about, and how Microsoft overhauled the latest ASP.NET release., Get acquainted with the new developer productivity features Master the new tools that build ...

    人物皮肤加光滑效果Face_Smoother1.5绿色汉化版

    《人物皮肤加光滑效果Face_Smoother1.5绿色汉化版》是一款专注于提升人物肖像照片质量的软件,尤其适用于那些希望优化肖像中人物皮肤质感的用户。这款工具的核心功能是通过智能算法实现对眼部皮肤和其他面部区域的...

    PLSQL.Developer v11.0.3.1770 主程序+ 中文包+keygen

    Changing a window with Ctrl-Tab, Ctrl-Shift-Tab and Window menu is now smoother Moving project files in groups other than "All" did not work correctly and is now disabled DDL for Enabling/Disabling a ...

Global site tag (gtag.js) - Google Analytics