views:

281

answers:

4

Hi,

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.

Thanks,

A: 

Dump prototype, I know that is not an easy solution, but it should be part of your roadmap.

Also use closures

mike clagg
A: 

If I remember correctly window script bloc has something to do with IE's internet security settings blocking script execution. "Did you noticed the yellow bar?" and questions like that should be appearing on the page.

It all depends on your security zone settings in IE, I think.

http://www.questiontools.com/faq_scriptwarning.html

jlindenbaum
A: 

WebKit's SunSpider test (which covers a wide selection of pure-JavaScript functionality). Here is the break down:

JavaScript Performance Rundown

as you can see, IE is slow on javascript.

source and more here.

Reigel
A: 

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.

Rui Carneiro