Knockoutjs在Internet Explorer中运行非常慢 [英] Knockoutjs operates extremely slow in Internet Explorer

查看:91
本文介绍了Knockoutjs在Internet Explorer中运行非常慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简要:我有一个包含KO代码的页面,该页面在Google Chrome,Firefox,Safari等中绝对运行很酷.但是Internet Explorer的性能却消失了.我尝试了IE10,IE11.渲染大约150行需要10到25秒.

In brief: I've got a page with KO-code that operates absolutely cool in Google Chrome, Firefox, Safari, etc. But the performance is gone in Internet Explorer. I tried IE10, IE11. It takes from 10 to 25 seconds to render about 150 rows.

详细信息:该页面代表用户的工作队列,其中显示了他们的任务.要求是不要在该页面上使用任何分页.表格的每一行至少要显示十二种变体(链接,按钮,输入,css样式,处理用户事件,自定义js插件等).产品上的平均行数为100-200 +.用户能够应用不同的过滤器和排序.

Details: There page represents a work queue for users, where their tasks are shown. The requirement is not to use any paging on that page. Each row of the table has at least a dozen of variants to display (links, buttons, inputs, css styling, handling user events, custom js plugins, etc.). The average number of rows on prod is 100-200+. User is able to apply different filters and sortings.

我已经尝试过的事情:

  • 减少了计算属性的数量(在可能的情况下更改为pureComputed)

  • reduced the number of computed properties (changed to pureComputed, where possible)

减少了使用 template if ifnot 绑定的次数(根据分析器,它们是最耗时的任务)-我尽可能使用 visible

reduced the number of using the template, if and ifnot bindings (according to profiler they are the most time consuming task) - I use the visible, where possible

试图使用 knockout-fast-foreach 自定义绑定(

tried to use the knockout-fast-foreach custom binding (https://github.com/brianmhunt/knockout-fast-foreach)

使用IE和Chrome工具配置了代码,以消除内存泄漏

profiled the code with IE and Chrome tools to eliminate the memory leaks

使用 ko.bindingReport.js ( https: //gist.github.com/kamranayub/65399fa247a6c182bc65 )

上面指定的方法在Chrome中将代码(根据 ko.bindingReport.js 进行调整)的速度提高了近两倍.但是IE仍然太慢-渲染大约需要10秒.

The approaches specifed above tuned the code (according to ko.bindingReport.js) almost two times faster in Chrome. But IE is still too slow - about 10 seconds for rendering.

Chrome :

Internet Explorer:

伙计,有什么想法吗?

推荐答案

表绑定提供了一种使用Knockout显示数据表的快速方法.表比嵌套的foreach绑定快大约十倍."

"The table binding provides a fast method for displaying tables of data using Knockout. table is about ten times faster than nested foreach bindings."

它声称速度提高了10倍. https://github.com/mbest/knockout-table

This claims to be 10x faster. https://github.com/mbest/knockout-table

这篇关于Knockoutjs在Internet Explorer中运行非常慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆