https://googlechrome.github.io/devtools-samples/jank// 官方案例css
http://www.javashuo.com/article/p-ogffqjfp-db.htmlhtml
http://www.javashuo.com/article/p-sypanrqx-bc.htmlgit
http://www.ruanyifeng.com/blog/2015/09/web-page-performance-in-depth.html 浏览器渲染过程github
http://www.javashuo.com/article/p-ruzqwaaq-g.html CSS动画的性能分析和浏览器GPU加速web
https://blog.csdn.net/leer168/article/details/25917093 深刻浏览器理解CSS animations 和 transitions的性能问题chrome
http://www.javashuo.com/article/p-myybgvmu-nq.html 说说动画卡顿的解决方案api
实际案例浏览器
http://www.javashuo.com/article/p-hbizibnk-bz.htmlbash
http://www.javashuo.com/article/p-vegqapcg-g.htmldom
<body>
元素的宽度通常会影响其子元素的宽度以及树中各处的节点。
window.requestAnimationFrame() 方法能够将某些代码统一放到下一次从新渲染时执行。具体是将js代码放在下一帧开始时执行。若是使用setTimeout 或 setInterval 来执行动画之类的视觉变化,其回调可能在帧的某个时间点执行,可能在末尾,这会使咱们丢失帧,致使卡顿。
function doubleHeight(element) { var currentHeight = element.clientWidth; element.style.width = (currentHeight / 2) + 'px'; element.style.height = '80px'; } var elements = document.getElementsByTagName('tr'); for (var i = 0; i < elements.length; i++) { doubleHeight(elements[i]); }
function doubleHeight(element) { var currentHeight = element.clientHeight; window.requestAnimationFrame(function () { element.style.height = (currentHeight * 2) + 'px'; }); }
2)页面滚动事件(scroll)
$(window).on('scroll', function() { window.requestAnimationFrame(scrollHandler); });
3)最适合用于动画