Boost script performance

by Geethalakshmi 2010-09-16 21:03:43

Boost script performance


One of the best kept secrets to boosting script performance is to cache your objects. Often times, your script will repeatedly access a certain object, as in the following demonstration:

<script type="text/javascript">
for (i=0;i<document.images.length;i++)
document.images[i].src="blank.gif"
</script>


In the above, the object "document.images" is what's accessed multiple times. The code to realizing it is inefficient, since the browser must dynamically look up "document.images" twice during each loop (once to see if i

Tagged in:

730
like
0
dislike
0
mail
flag

You must LOGIN to add comments
Tags
More...
Comments