Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Script too slow warning messages #80

Closed
valtido opened this issue Nov 7, 2013 · 8 comments
Closed

Script too slow warning messages #80

valtido opened this issue Nov 7, 2013 · 8 comments

Comments

@valtido
Copy link

valtido commented Nov 7, 2013

Hi Guys,

I got a table of ~2000 records, when I try to sort, there is a small delay (1 or 2seconds) on chrome,

However on Firefox, this gives a native pop up saying the script is too slow, and wants to continue, stop it...

I am using a table of 10 columns and 1879 table rows....(if you are going to test this, maybe try a few thousand records to make it work that much harder.

Is there anything I can do to optimise this?

if you have any questions do let me know I will try and answer...

@valtido
Copy link
Author

valtido commented Nov 7, 2013

I (think) the problem could be because you are sorting it by moving one tr at a time, which means the browser has to draw this tr each time is moved, and maybe maybe, could be that the same TR moves up and down one too many times unnecessarily, this maybe can be avoided if the data is sorted using arrays and then manipulate the dom with the result. (it may help speed up the sorting)

Also this may help ...

http://stackoverflow.com/questions/1340589/javascript-are-loops-really-faster-in-reverse#13136778

@joequery
Copy link
Owner

joequery commented Nov 7, 2013

Thanks for the bug report. Your second comment is incorrect, though. I'm not sorting by moving the trs around. See here. That returns an array, and the other columns are rearranged according to the sort map (so that they match the array sorted). The dom is only touched in one spot, which is here.

@valtido
Copy link
Author

valtido commented Nov 8, 2013

oh I see, I was just suggesting it, do you think it could be that tables are pretty slow ?

or have any idea as to what it could be ?

@joequery
Copy link
Owner

joequery commented Nov 8, 2013

Drawing that many elements may just be too slow. It's probably why most table plugins paginate.

@joequery
Copy link
Owner

joequery commented Nov 8, 2013

You could time how long it takes to reach right before the .append() via https://developers.google.com/chrome-developer-tools/docs/console-api#consoletimelabel, and then see how long the append() takes. I bet the actual rendering of the elements is the bottleneck and not the sort.

@valtido
Copy link
Author

valtido commented Dec 4, 2013

when you append, it's a lot faster to use $('table').emty() then append one by one... than trying to redraw the table with the new row on a new position...

Could this be a possible approach ?

@joequery
Copy link
Owner

joequery commented Dec 4, 2013

We aren't appending one by one. We append the entire HTML

@joequery
Copy link
Owner

#97 aims to provide performance improvements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants