Performance questions: lazy initialization + striping

Performance questions: lazy initialization + striping

YvesYves Posts: 2Questions: 0Answers: 0
edited March 2014 in DataTables 1.9
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.

Replies

  • idialloidiallo Posts: 6Questions: 0Answers: 0
    Did you disable default sorting ? (options.aaSorting = "")
  • YvesYves Posts: 2Questions: 0Answers: 0
    Yes.

    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.
  • idialloidiallo Posts: 6Questions: 0Answers: 0
    OK. I would also be interested by a stripped-down, faster init option.
  • allanallan Posts: 61,972Questions: 1Answers: 10,160 Site admin
    First thing I would try suggesting if to use the latest 1.10 nightly. 1.10 has a lot of performance improvements in it, and there are a few more in the nightly over the latest beta. I've had good reports about speed improvements, particularly in older browsers like IE8.

    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
  • idialloidiallo Posts: 6Questions: 0Answers: 0
    edited May 2014

    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.

This discussion has been closed.