views:

952

answers:

5

Hello, I have a table with about 250 rows (may double within 6 months), and 50 columns on this page (warning: slow with IE). I'm using the JQuery Table sorter. But it is too slow with IE 7: it gives a warning about a slow javascript, and ask if I want to stop it. I've spent a lot of time to improve performances, so it works fine for all other browsers:

  • sort text and digit only
  • removed all but 2 parsers
  • created an extra table that contains all the values, much faster than doing node.textContent() for each cell
  • removed lowercase, trim, etc.

My version of the javascript is here. I think I cannot optimize it much more. I am looking for another fast implementation of a table sorter, or any good optimization I may have forgot, so that IE 7 won't complain about the execution time.

Edit: I've disabled sorting on 35 columns, it is still too long for IE

A: 

Most JScript solutions that work slow have a lot of interaction with the DOM. At the moment that you're doing DOM-level edits row-per-row it will take long in IE. If you're building the HTML in a string and then put it at once in the DOM, it'll go a lot quicker. (There were some demos at the last PDC showing exactly that.)

But the moral of the story here is that your table is quite big. You might think of using REST, with table paging and sorting and some server-side logic. I think that can be a lot quicker and will work fine with JQuery. (And it is still an AJAX solution.) It might even save you some bandwidth...

Hope this helps.

Jeroen Landheer
+4  A: 

I use this extremely fast table sort javascript library. (not JQuery)

Luis Melgratti
I've used this in the past and it works really well. Some times you have to use their custom attributes for dates, but overall it is very solid.
hunter
Very nice library but what if i don't want to use all headers for sorting?
Sarah
A: 

One of the worst things you can do is use eval() and I see that in your code. You should profile your code and see where the bottleneck is.

epascarello
That eval() looks like it is called once per sort.. but it does look like it's doing something ugly.
Ryan Graham
A: 

Problem in the function buildCache(table) Line 219 Error : 'all_data' non defined

+1  A: 

Commenting out any references to applyWidget and their respective bindings as well as removing unused parsers made a big difference to a 500 row table in IE6 (yeah, I know, but it still won't die).

GlennG