2

I encountered a slow script warning in IE 9 while using jscrollpane on a page containing a scrollable (i.e. some jscrollpanes inside) overlay with a bunch of content. In Firefox 8 everything works fine and the page is build up quickly. On IE it takes a lot of time (about a minute) and collapsing/expanding one of the scrolled regions (i.e. showing/hiding) causes the page to freeze again for long time. Obviously this is only a problem in conjunction with IE.

The same page but without the .jscrollpane()'s added is in IE as fast as in Firefox.

I'm using jscrollpane 2.0.0.beta10 and jquery 1.7, but it happens to be the same with jquery 2.0.0.beta9 and jquery 1.6.

John Conde
  • 217,595
  • 99
  • 455
  • 496
  • 2
    I'm surprised IE doesn't give that warning on all websites! I know, bad joke. Is the `jscrollpane()` called in a document `ready` event handler? ([jquery ready()](http://api.jquery.com/ready/)) – Tim S. Nov 15 '11 at 12:03
  • 2
    With some debugging I found the answer: In jquery.jscrollpane.js, function initialiseVerticalScroll() uses a very inperformant selection (at least for IE) to resize the vertical scrollbar: container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').each( Especially when *container* contains a lot of elements it seems to trouble IE. A fix is very simple, due to the fact that *.jspVerticalBar* is already known as *verticalBar*: verticalBar.find('>.jspCap:visible,>.jspArrow').each( Same Problem/Solution should apply to the corresponding horizontal bar. – user1047487 Nov 15 '11 at 16:10
  • 1
    You should post it as an answer and accept it. – John Conde Nov 16 '11 at 05:49
  • 1
    Please do post it as an answer as John Conde suggested. – Michael Myers Jan 13 '12 at 19:29

1 Answers1

2

Posting user1047487's answer from the comment so it is easier to find (also adding some formatting).

In jquery.jscrollpane.js, function initialiseVerticalScroll() uses a very inperformant selection (at least for IE) to resize the vertical scrollbar:

container.find('>.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow').ea‌​ch

This is especially slow when container contains a lot of elements.

A fix is very simple, due to the fact that .jspVerticalBar is already known as verticalBar:

verticalBar.find('>.jspCap:visible,>.jspArrow').each

Same Problem/Solution should apply to the corresponding horizontal bar.

Chad DeShon
  • 4,732
  • 6
  • 28
  • 29