1

我有一个 Web 应用程序屏幕,其中包含许多动态创建的 JQuery UI 手风琴。我正在遍历传入的 JSON 字符串并动态创建手风琴,如下所示。

for (i in json.panels) {

   var accordionName = json.panels[i].panelName;
   var isExpanded = json.panels[i].expand;
   var activeProperty = (isExpanded) ? 0 : false;

   var accordElemId = "accordion_"+i;
   var accordDiv = '<div id="' + accordElemId + '"></div>';
   var accordion = $("#"+accordElemId );

   var startTime = new Date().getTime();

   accordion.accordion({
      collapsible: true,
      heightStyle: "content",
      active: activeProperty,
      animated : false
   });

    var endTime = new Date().getTime();
    console.log("Time for "+accordionName+"="+(endTime - startTime));

}

然后我比较了在 IE8 和 IE10 中创建每个手风琴的时间

在 IE8 中,我发现它真的很慢,当我浏览页面时,性能不断下降。请看下图,时间以毫秒为单位。

1)

LOG: ----------------------------start -------------------------------------
LOG: Time for Patient Address =  16
LOG: Time for Current Legal Status =  32
LOG: Time for Alerts and Risk Factors =  0
LOG: Time for Current Wards/Programs =  16
LOG: Time for Open Orders =  0
LOG: Time for RAI-MH Form =  0
LOG: Time for RAI =  16
LOG: Time for OCAN-C =  31
LOG: Time for LD =  0
LOG: --- Diff create ajaxURL =  0
LOG: ----------------------------end -------------------------------------

2)

LOG: ----------------------------start -------------------------------------
LOG: Time for Patient Address =  16
LOG: Time for Current Legal Status =  47
LOG: Time for Alerts and Risk Factors =  32
LOG: Time for Current Wards/Programs =  16
LOG: Time for Open Orders =  15
LOG: Time for RAI-MH Form =  110
LOG: Time for RAI =  140
LOG: Time for OCAN-C =  141
LOG: Time for LD =  31
LOG: --- Diff create ajaxURL =  0
LOG: ----------------------------end -------------------------------------

3)

LOG: ----------------------------start -------------------------------------
LOG: Time for Patient Address =  62
LOG: Time for Current Legal Status =  485
LOG: Time for Alerts and Risk Factors =  15
LOG: Time for Current Wards/Programs =  219
LOG: Time for Open Orders =  391
LOG: Time for RAI-MH Form =  62
LOG: Time for RAI =  250
LOG: Time for OCAN-C =  391
LOG: Time for LD =  110
LOG: --- Diff create ajaxURL =  0
LOG: ----------------------------end -------------------------------------

然后我尝试了 IE 10,它超级快,并且与性能一致

----------------------------start ------------------------------------- 
Time for Patient Address =  7 
Time for Current Legal Status =  5 
Time for Alerts and Risk Factors =  5 
Time for Current Wards/Programs =  6 
Time for Open Orders =  6 
Time for RAI-MH Form =  6 
Time for RAI =  4 
Time for OCAN-C =  4 
Time for LD =  4 
--- Diff create ajaxURL =  0 
----------------------------end ------------------------------------

你们对此有什么想法吗?感谢您的帮助

谢谢,凯思

4

0 回答 0