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)最適合用於動畫