tablesorter icon indicating copy to clipboard operation
tablesorter copied to clipboard

sluggish sorting time unless rows hidden

Open TheeOhioState opened this issue 3 years ago • 1 comments

Few questions

I setup 2 examples - both plain jane functions - no widgets - nothing added to basic setup

$(function() { $("#playerStats").tablesorter(); });

Both examples are identical html and sort function , only difference is one has css to hide all but 1st 50 rows

Example 1 sorts very slow https://mflscripts.com/mfl-apps/mfl_manager/SlowSort.html

Example 2 much faster simply using css to hide all but first 50 rows https://mflscripts.com/mfl-apps/mfl_manager/FastSort.html

Question - why is this happening since sorting checks its array and all 2819 rows are checked in either case ? Is it just a matter rendering off the visible rows , since 1 example stays hidden with css and the other does not ?

Question 2 - I'm assumed this script creates an array on initial load and uses it to filter the columns. I know if I remove a row from the DOM it gets rebuilt on sort. Is there any variable to set the number of rows displayed on initial load and/or on sort ? So , for example all but 50 rows are removed from DOM on load and on each sort. I think this would greatly speed up the sorting if the issue is from number of rows and rendering them hidden or not

If you have any ideas on how to speed up the sorting while allowing all rows to show , would be grateful , if not a variable to show x amount of rows on load and on sort would be great !

TheeOhioState avatar Mar 08 '22 23:03 TheeOhioState

Hi @TheeOhioState!

Yes, TS renders all the rows when sorting and it is very slow especially when you have a lot. If you want to speed up pretty much everything, try out the pager widget or pager plugin.

Mottie avatar Mar 10 '22 01:03 Mottie