-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
【课外】8.15 性能问题 #12
Comments
答案参考:https://calendar.perfplanet.com/2021/reducing-property-access/ 如果自己心目中的答案比这个差可能要思考下是不是自己平时对运行性能不太关注。 |
心目中的答案就是这样的[狗头],避免循环操作dom引起的重绘、重排,把所有改变通过createDocumentFragment对象、JQ对象,html文本等形式缓存,最后一次性插入 |
并不一定需要用createDocumentFragment,实际上跟把字符串拼装好再innerHTML性能差不多,差别只在于用createDocuemntFragement可以拿到被插入的对象,这样可以做些其他事情。 |
createDocuemntFragement的使用场景是把复制的dom对象进行组装,因为要保留它已绑定的事件 |
下面这段代码应当怎么优化性能更好:
The text was updated successfully, but these errors were encountered: