This method is used to hide columns in a table based on a collection of metadata json objects. There is an object per column in the table. Currently on a table that has ~500 rows and ~15 columns with 6 being hidden this method takes ~2 seconds to execute.
I am attempting to optimize it to be faster. Any suggestions?
function hideHiddenColumns() {
if (tableMetaData.length) {
for (var index = 0; index < tableMetaData.length; index++) {
var item = tableMetaData[index];
if (!item.DisplayFlag) {
$table.find('th:nth-child(' + (index + 1) + '), td:nth-child(' + (index + 1) + ')').hide();
}
}
}
}