Speed advise using metadata plugin
Hello,
I'm using jQuery 1.4.2 and metadata plugin (latest versión) to iterate over 3000 elements. The elements ar TRs of tables, and I need to show or hide them following some rules. This is a typical element I need to show or hide:
- <tr dim="{ta_1,en_G,re_V,se_3,tsk}" id_col="GVNSEG_WINNAT_NOM" style="display: none;">
When I need to show a group of elements, I made the following:
-
var selectorSeccionesActivadas += '[dim*=se_3],[dim*=se_5],[dim*=se_6],[dim*=se_9]'; // This is runtime generated
var tabCache = $(tabCacheGet(tabNumActual));
-
tabTempShow = $(tabCache).filter('[dim*=en_'+goEnv+'][dim*=re_'+goRed+']'+hiddenSelector+',' +
'[dim*=en_G][dim*=re_G]'+hiddenSelector+',' +
'[dim*=en_'+goEnv+'][dim*=re_G]'+hiddenSelector+',' +
'[dim*=en_G][dim*=re_'+goRed+']'+hiddenSelector
).filter(
selectorSeccionesActivadas).filter(':not([dim*=adv])').show();
The filter to hide elements is similar to that one. As you can see, I save to cache the filter of the first parameter of the "dim" selector:
- function tabCacheGet(tabNum) {
if ( cacheTab[tabNum] != null) {
return cacheTab[tabNum];
} else {
return cacheTab[tabNum] = $(trCacheGet()).filter('[dim*=ta_'+tabNum+',]');
}
}
So when I need to show a set of elements, I run on the cached "ta" parameter, and then I filter the next parameters. What I found is that Firefox runs this very-fast (almost real-time), but IE7 is slower, showing up the "this script is taking up too much time. Do you want to stop it?" message. Do you guys know a way of speeding up this
The metadata plugin expresion I'm using was copied from some example found on the net (perhaps on the plugin homepage):
-
<script type="text/javascript" src="comun/jquery.metadata.js"
></script>
-
<script type="text/javascript">
jQuery.extend(jQuery.expr[':'], {
meta: "!m[3]||((p=m[3].split('='))&&(p.length>1?$(a).metadata()[p[0]]==p[1]:$(a).metadata()[p[0]]))"
});
</script>
Thanks a lot in advance,
Luis Miguel