Hello all,
I have an application that I did not write and I am trying to optimize. It is taking 15 seconds to load on IE and about 1 second on Chrome and Firefox. Problem is it must work for IE. Here is one piece of code that is slow (among many). This code is running through the each() 332 times.
$(ds_top_tr).each( function( ) {
// filter out when there are no inputs in the row.
if ( $(this).find("input,select,textarea").length > 0 ) {
if ( $(this).find(".error-indicator").length === 0 ) {
$(this).append('<td class="error-indicator"><img height="15" border="0" width="15" src="images/nondefault.gif"></td>');
}
}
$("table table").parent( ).next( ).remove( );
var tr = this;
// find the row default value
// defaultValue = $(this).find("td:eq(7)").text( );
$(this).find("select,textarea,input").change( function( ) {
defaultValue = $(this).attr("__default_value");
//Modified 9/19 to hide the error indicators
// if ($(this).find("option:selected,textarea,input").val( ) === defaultValue || $(this).find("option:selected").val( ) === nd ){//|| $(this).find("option:selected").val( ) === "No" ) {
tr_find_select = $(tr).find("select");
if ( $(tr).find("option:selected").val( ) === "For components below" ) {
$(tr).find(".error-indicator").show( );
} else if ($(tr).find("option:selected,textarea,input").val( ) === defaultValue || $(tr).find("option:selected").val( ) === nd ){//|| $(this).find("option:selected").val( ) === "No" ) {
$(tr).find(".error-indicator").hide( );
} else if ( $(this).attr("type") !== "radio" ) {
$(tr).find(".error-indicator").show( );
}
}).change( );
} );
Can anyone suggest how I might improve the performance?
Thank you!