jennschiffer / timbles.js

a very simple jQuery plugin for tables, made by the person who literally did not invent tables
MIT License
38 stars 4 forks source link

Improve timbles initialization speed #8

Closed edelooff closed 8 years ago

edelooff commented 9 years ago

Again, not a change that's quite ready for PR, but I'd be happy to get feedback on while it's progressing.

To speed up initialization (currently only for the existing table, but the JSON-generated one is next), I've reworked the way the to-be-sorted column is selected. Instead assigning an ID to every column head and classes to all cells, the current version only assigns a data attribute to the column head and selects the nth cell in every row based on that.

This improves init times by an order of magnitude my large test table (2300x6 rows/cols), reducing from ~300ms to ~30ms. Selecting the set of values to sort by seems to be positively affected as well, though obviously less dramatically (-30%). I haven't checked whether this degrades performance on tables with many columns, which may be a concern.

As a bonus, it gets rid of the slightly ugly hack I introduced to create anonymous column-head IDs. IDs are now actually optional. They can still be used as a sorting key, but they aren't

The current changes all happen in 21266ee974627b91e442b622a93ec0af29b17fb1 (branch event-refactor which GitHub won't allow me to link).

edelooff commented 8 years ago

Resolved by #9