Recently, I had very large data tables that would consume from 15 seconds to a minute of processing when making changes due to all the DOM manipulations being performed. I got it up to 1 second in all browsers, but IE (it takes 5-10 seconds in IE8).
The biggest gain I found was to remove the parent I was working with from the DOM by making my changes and then reinserting it back into the DOM (in my case tbody ).
Here you can see two corresponding lines of code that gave me a huge performance boost (using Mootools, but can be ported to jQuery).
update_table : function(rows) { var self = this; this.body = this.body.dispose(); //<------REMOVED HERE rows.each(function(row) { var active = row.retrieve('active'); self.options.data_classes.each(function(hide, name) { if (row.retrieve(name) == true && hide == true) { active = false; } }); row.setStyle('display', (active ? '' : 'none')); row.store('active', active); row.inject(self.body); //<--------CHANGES TO TBODY DONE HERE }) this.body.inject(this.table); //<-----RE-INSERTED HERE this.rows = rows; this.zebra(); this.cells = this._update_cells(); this.fireEvent('update'); },
tj111
source share