SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 243 | Next

Richard Wagner

"Professional iPhone and iPod touch Programming: Building Applications for Mobile Safari"

getTime() - start;
document.write( ???String concat method: ??? + duration + ??? < /br > ??™);
}
Chapter 9: Bandwidth and Performance Optimizations
219
function intermStringTable(){
var start = new Date().getTime();
var buf = ??? < table > ???;
for (var i=0; i < 10000;i++){
var row = ??? < tr > ???;
for (var j=0;j < 40;j++){
row += ??? < td > < i > ??? + ???content??? + ??? < /i > < /td > ???;
}
row += ??? < /tr > ???;
buf += row
}
buf += ??? < /table > ???;
var duration = new Date().getTime() - start;
document.write(???Intermediate concat method: ??? + duration + ??? < /br > ??™);
}
< /script >
< body >
< /body >
< script type=???text/javascript??? language=???javascript??? >
stringTable();
intermStringTable();
< /script >
< /html >
What to Do and Not to Do
You will want to be sure to avoid with statements, which slow down the processing of the related code
block. In addition to the fact that with is inefficient, it has also been depreciated in the JavaScript standard.
Second, avoid using eval() in your scripts. It is very expensive from a performance standpoint.
Besides, you should be able to develop a more efficient solution rather than resorting to eval() .
Comments add to readability and manageability, but be wise in their usage.


Pages:
231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255