Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript Running slow in IE - What does "JScript - window script block" mean?

Javascript is running extremely slow on IE on some pages in our site.

Profiling seems to show that the following methods are taking the most time:

Method                          count inclusive time exclusive time)
 JScript - window script block  2,332      237.98       184.98
 getDimensions                      4          33           33
 eh                               213          32           32
 extend                           446          30           30
 tt_HideSrcTagsRecurs           1,362          26           26
 String.split                     794          18           18
 $                                717          49           17
 findElements                     104      184.98           14

What does "JScript - window script block" do?

We are using jquery and prototype.

like image 423
SharePoint Newbie Avatar asked Feb 27 '23 01:02

SharePoint Newbie


2 Answers

From my experience the main issues on prototype are these:

$$ selectors

Try to use $ selector with down or select instead.

observes

Don't use to many observes. If you want a click handler for more than one element use ids and a global document observe:

document.observe('click', this.clickHandler.bindAsEventListener(this));

clickHandler: function(e)
{
    var elt = e.element();
    while (Object.isElement(elt)) {
         switch (elt.id) {
              //do your stuff here
         }
         elt = elt.up(); //Bubbling
    }
}

CSS selectors with unsupported features on IE

This code will work, but performance will decrease.

<input type="checkbox"/> //HTML
$$('[type=checkbox]') //Prototype

Using a class name will increase performance in this situation:

<input class="checkbox" type="checkbox"/> //HTML
$$('.checkbox') //Prototype

Search on DOM tree

Anything else that require DOM tree search.

like image 100
Rui Carneiro Avatar answered Apr 25 '23 16:04

Rui Carneiro


I know this question is old, but for anyone getting to it from search results.

I'm pretty sure that "JScript - window script block" is the IE developer tools profiler's term for javascript that's executing in the global scope or in an anonymous function.

like image 31
Davey Avatar answered Apr 25 '23 16:04

Davey