simple-datatables icon indicating copy to clipboard operation
simple-datatables copied to clipboard

Strange slow down

Open notshi opened this issue 3 years ago • 1 comments

Thanks very much for this really straightforward and simple to use plugin.

I am currently using it here.

I found that sorting the largest table so that it is descending takes a long time, which is strange because ascending is fast. Am I doing something wrong?

notshi avatar May 20 '21 23:05 notshi

I'm facing the same issue, sorting an array of approximately 8,000 entries takes 1 to 2 seconds.

I tried to add a loader, however, as soon as you click on the sort button, all JavaScript execution is "blocked".

There's the issue : https://www.loom.com/share/830b1e6ddbff47e4b85bea5424141ea8 --> when I click, console log is showing nothing, and when sort is done, it's going to continue the JavaScript execution.

My code :

let tableHTMLLoader = document.querySelector("#table-loader");
 table.on("datatable.init", () => {
    document.querySelectorAll(".dataTable-sorter").forEach(sortButton => {
       sortButton.addEventListener("click", e => {
          console.log("display loader");
          console.log(tableHTMLLoader);
          tableHTMLLoader.style.display = "flex";
       });
    });
 });

table.on("datatable.sort", () => {
   console.log("Hide loader. Disable to test the loader display on `init` event.");
   console.log(tableHTMLLoader);
   // tableHTMLLoader.style.display = "none";
});

MKlblangenois avatar Jul 26 '21 09:07 MKlblangenois

Hey @MKlblangenois @notshi , in version 6 we have a lot fewer dom updates, so that really helps. Please check it out!

johanneswilm avatar Jan 11 '23 13:01 johanneswilm

Thanks, @johanneswilm - can confirm that it is a lot faster!

It also looks like there has been some style changes since then too so might be a good time to have a poke through and see what else has been updated.

notshi avatar Jan 12 '23 16:01 notshi

@notshi Take a look at the upgrade instructions in the README.md.

johanneswilm avatar Jan 12 '23 16:01 johanneswilm

This is great, many thanks, @johanneswilm! This really helped :)

notshi avatar Jan 13 '23 16:01 notshi