Interesting find: myfunction(’value’) vs myfunction(this.myval)

I develop Intranet apps with IE as the supported browser, so how other browsers are effected are unknown. I had an app that displays 1000+ lines on a single page and each line had an inline function “myfunction(’valueID’)” and would render to the page much slower than the actual querry would take to return the data. At first we thought there was just a lot of data and it just took time to render.
Example 1: <img src=”img.gif” mce_src=”img.gif” onclick=”myfunction(’456-12′)”>

Recently we found that if we put the “valueID” in an attribute and referenced it through this.attrName it display much faster.
Example 2: <img src=”img.gif” mce_src=”img.gif” onclick=”myfunction(this.valueID)” valueID=”456-12″>

One of the pages with “ALL” results, returned over 5000 records. This page went from a nearly 2 minute query-load-display time down to a 25-30 second time to display.

I just could NOT have imagined that it would have made such a significant difference. Further testing revealed that if the variable remained constant in the functions it was also very fast, but when they were all unique it slowed down again.  

We concluded: (atleast in IE) The browser has to allocate memory for the variables in the functions as it tries to display the page, but not for the attributes. also posted on Webmaster World : Interesting find: myfunction(’value’) vs myfunction(this.myval)

0 comments ↓

There are no comments yet...Kick things off by filling out the form below.

Leave a Comment