views:

465

answers:

1

I've appended a sortable jQuery plugin to my list of divs using 1.4.1 jQuery. The function that is called on the page load is pretty simple.

$(function()
{ 
 $('#divEditFieldOrderModal_FieldList').sortable(
 {
  axis: 'y',
  cursor: 'pointer',
  placeholder: 'sortOrderPlaceholder'
 });
});

This divEditFieldOrderModal_FieldList contains something like 20 items, each div has a small text string inside, nothing special. Running this page in FF or Chrome i see that everything runs smoothly, no troubles. But when i try the same thing in IE8 (without compatibility mode) everything goes so slow that the mouse is hardly moving.

When trying to profile JS with embedded profiler i see that the function called 'data' contains the biggest value in 'Exclusive time' column. I profiled for 2secs approximately, moving one item from bottom to the top of the list.

data Count:5 399     Exclusive time:124,00

BTW, i tested the sortable plugin official examples in IE8, everything is running fast and perfect. Surely my page is more loaded with controls and tables then the examples...

Maybe someone knows what can cause this problem in IE8 and what can I do about it?

P.S.: It runs smoothly in IE7 compatibility mode.

A: 

Well if it works fine in IE7 and you are developing to support IE7 anyhow why not jsut force IE7 compat mode with an HTTP header or Meta Tag? Granted its sort of an "avoidance" strategy, but personally why waste time if you dont have to?

That said itd be interesting to get a diagnosis. Can you post your code?

prodigitalson
Looks like IE8 inner searching mechanisms by id (which jQuery user quite often) is not optimized at all. When my page gets bigger, starting to contain more that 1k divs and big tables, the 'sortable' actions is slowing down at crazy rate. I decided to add a Meta tag as you suggest. Thanks.
GregoryM
@Gregory: No problem. Can you post the link to the info on this for myself and others? I was totally unaware of this and it would be very good to keep in mind.
prodigitalson
@prodigitalson: I'm not 100% sure what mechanism jQuery uses to iterate through elements, I will be investigating this matter digging into jQuery source code; but you can compare the IE8 and other browsers getElementById search speed here http://www.coolphptools.com/tests/get-id-v-dot.html. I wonder why this all works fine in IE7 though it's not more powerful than IE8...
GregoryM
@prodigitalson: But anyway, I think the problem is in search mechanisms. 'Sortable' starts to work much slower when DOM tree gets bigger.
GregoryM