knockout.js is too slow in filling observableArray

2020-07-23 03:17发布

I create test for the comparing angular and knockout:

    items = self.items();
    // ...
    self.items.valueHasMutated();

http://jsfiddle.net/imbolc/z7bkz/9/embedded/result/

Is this test correct? Do you know way for increase KO filling speed?

1条回答
冷血范
2楼-- · 2020-07-23 04:09

I did not thoroughly compare the logic betweens your different tests, but I do know that there are some issues with how Chrome processes text nodes as described here: https://github.com/SteveSanderson/knockout/issues/793

If you strip the text nodes from your inline KO template, then you see a big boost in performance in Chrome.

Like:

<ul id="ko-list" data-bind="foreach: items"><li>ko: <span data-bind="text: val"></span></li></ul>

Updated sample: http://jsfiddle.net/rniemeyer/tsTmZ/

Sample results in the latest Chrome:

jquery: 45 ms 74 ms

angular: 171 ms 199 ms

knockout: 109 ms 25 ms

查看更多
登录 后发表回答