如何加快IE8中innerHTML的读取速度? [英] How to speed up the reading of innerHTML in IE8?

查看:197
本文介绍了如何加快IE8中innerHTML的读取速度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有DataTable插件的JQuery,现在我在下一行中遇到了很大的性能问题。

I am using JQuery with the DataTable plugin, and now I have a big performnce issue on the following line.

aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220

我有一个ajax调用,以及HTML格式的结果字符串。我把它们转换成HTML节点,那部分还可以。

I have a ajax call, and result string in HTML format. I convert them into HTML nodes, and that part is ok.

var $result = $('<div/>').html(result).find("*:first");
// simlar to $result=$(result) but much more faster in Fx

然后我激活启用普通表的结果到可排序的数据表。速度在Fx中是可接受的(900行约为4秒),但在IE8中不可接受(超过100秒)。

Then I activate enable the result from a plain table to a sortable datatable. The speed is acceptable in Fx (around 4sec for 900 rows), but unacceptable in IE8 (more then 100 seconds).

我使用buildin探测器深入检查,并且发现上面的单行占用了99.9%的全部时间,我怎样才能加快速度呢?我错过了什么?

I check it deep using the buildin profiler, and found the above single line take all 99.9% of the time, how can I speed it up? anything I missed?

            nTrs = oSettings.nTable.getElementsByTagName('tbody')[0].childNodes;
            for ( i=0, iLen=nTrs.length ; i<iLen ; i++ )
            {
                if ( nTrs[i].nodeName == "TR" )
                {
                    iThisIndex = oSettings.aoData.length;
                    oSettings.aoData.push( {
                        "nTr": nTrs[i],
                        "_iId": oSettings.iNextId++,
                        "_aData": [],
                        "_anHidden": [],
                        "_sRowStripe": ''
                    } );

                    oSettings.aiDisplayMaster.push( iThisIndex );

                    aLocalData = oSettings.aoData[iThisIndex]._aData;
                    nTds = nTrs[i].childNodes;
                    jInner = 0;

                    for ( j=0, jLen=nTds.length ; j<jLen ; j++ )
                    {
                        if ( nTds[j].nodeName == "TD" )
                        {
                            aLocalData[jInner] = nTds[j].innerHTML; // jquery.dataTables.js:2220

                            jInner++;
                        }
                    }
                }
            }


推荐答案

尝试使用 YUI DataTable 。我扔它的任何大表都非常快。您可以将它与JQuery一起使用而没有任何问题。

Try using the YUI DataTable. It is very quick for any large table that I throw it at. You can use it with JQuery without any issues.

例如: http://paulisageek.com/compare/cpu/

这篇关于如何加快IE8中innerHTML的读取速度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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