Why is my datatables so slow?
Why is my datatables so slow?
I am using datatables in my website. This is the link - http://startupstrong.com/mentor-list/
The website loads really slowly. I have two problems due to the slow speed -
1) The table sorting happens after page load -> Initially the table is sorted as it appears in the markup. Then after 3-4 seconds the page is sorted in alphabetical order. This is not looking very good.
2) Another problem is that the datatable search filter box appears in the end of the loading. It will be much better if everything loads together.
What could be the reason for this? Any help is much appreciated.
Answers
I don't think it is DataTables that is slow, but rather the
admin-ajax.php
file (which is called 9 times at page load!). The longest it takes to respond is 10 seconds, and it doesn't even appear to be returning anything.Attached is a screenshot of the Chrome network console. I'd suggest you try to optimise your page loading.
Allan
Hey Allan, I removed the admin-ajax.php problem.
The loading is a little faster but the same problems still persists -
1) The table sorting happens after page load -> Initially the table is sorted as it appears in the markup. Then after 3-4 seconds the page is sorted in alphabetical order. This is not looking very good.
2) Another problem is that the datatable search filter box appears in the end of the loading. It will be much better if everything loads together.
What do you think?
You decided this question? I just tried to restart the computer and everything works fine. maybe you'll find some other solution. good luck!
It looks like admin-ajax.php is still being loaded at the above address. Moreover, the page as a whole is taking 10.65 seconds to load for me - which would really need to be reduced. Its loading almost 1MB of data as well.
In the code you have:
So even once the DOM has been loaded, there is an artificial delay.
Once the DataTable is run, it loads very quickly - 100mS in Chrome's dev tools for me.
I don't believe that this is a DataTables issue. To check, I'd suggest optimising without DataTables first.
Allan