Performance questions: lazy initialization + striping
Performance questions: lazy initialization + striping
Yves
Posts: 2Questions: 0Answers: 0
I like DataTables, and for small tables, it is the best I have come across so far. For large tables, especially in combination with older browsers like IE8, but even newer ones, it is slow.
Is there a switch or variable which allows me to do lazy initialization of DataTables?
I frequently use DataTables just for sorting tables, so no pagination, no searches, ... As users often have no need to sort columns, it would be nice if the initialization of DataTables would be postponed until the first time the user actually clicks on a column header and requests a sort. This would of course make this 'first' sort a lot slower, but that is something that users can comprehend as they know something is going on based on a request they made. The initialization DataTables does on startup by default just seems like a performance issue to them.
Is there a switch to indicate that the original table is already striped?
I can set the 'even' and 'odd' classes (or whatever stripe classes you want) while generating the table. There is no need for DataTables to go over all rows and call the jquery addClass and removeClass functions. According to my profiling, this costs a lot of time.
Is there a switch or variable which allows me to do lazy initialization of DataTables?
I frequently use DataTables just for sorting tables, so no pagination, no searches, ... As users often have no need to sort columns, it would be nice if the initialization of DataTables would be postponed until the first time the user actually clicks on a column header and requests a sort. This would of course make this 'first' sort a lot slower, but that is something that users can comprehend as they know something is going on based on a request they made. The initialization DataTables does on startup by default just seems like a performance issue to them.
Is there a switch to indicate that the original table is already striped?
I can set the 'even' and 'odd' classes (or whatever stripe classes you want) while generating the table. There is no need for DataTables to go over all rows and call the jquery addClass and removeClass functions. According to my profiling, this costs a lot of time.
This discussion has been closed.
Replies
Even without doing any sorting DataTables still loops over all cells to build an internal datastructure. I am looking for away to delay this step until a sort request by the user is made.
However, with regard to lazy init, the closest DataTables gets at the moment is lazy init with server-side processing: http://datatables.net/release-datatables/examples/server_side/defer_loading.html .
There isn't a way, at the moment, of having DataTables so more or less nothing on initialisation when client-side processing. It is an interesting idea though, and I might explore that in a future version.
Allan
I've benchmarked the loading performances of the 1.10rc.
For our use case, 1.10 is a lot slower than 1.9.4.
We're using ColVis and ColReorder extensions.
For a 600-lines table whe have about 5.5s compared to 2.5s with 1.9.
The worst offender is fnSetColumnVis (from 34ms to 2180ms), but everything is slower, for instance fnSort goes to 515ms from 334ms.
Tested on Chrome.