createDocumentFragement
var frag = document.createDocumentFragement()
frag.appendchild(li)
doms.ul.appemd(frag)
网站图标
<link rel="shortcut icon" href="./assets/favicon.ico" type="image/x-icon" />
<link rel="stylesheet" href="./css/index.css" />
requestAnimationFrame:优化动画和渲染的利器
不会导致 reflow。 requestAnimationFrame 是浏览器提供的一个用于优化动画和渲染的API。它基于浏览器的刷新率,调度回调函数的执行,以确保动画和渲染的流畅性和高性能。 使用requestAnimationFrame,开发者可以在每个浏览器刷新帧之前请求执行一个函数。浏览器会在适当的时机调用这个函数,以保证动画和渲染的协调性。通过与浏览器的合作,requestAnimationFrame可以避免不必要的渲染操作,并确保动画的效果更佳平滑。 requestAnimationFrame在现代化浏览器中得到广泛支持,并成为实现高性能动画和渲染的首选方式。