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 236 | Next

Richard Wagner

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

Minify
combines, minifies, and caches JavaScript and CSS files to decrease the number of page requests that a
page has to make. To do so, it combines multiple style sheets and script libraries into a single download
( code.google.com/p/minify ).
Chapter 9: Bandwidth and Performance Optimizations
214
JavaScript Performance Optimizations
The performance of JavaScript on iPhone and iPod touch is much slower than on the Safari desktop
counterparts. For example, consider the following simple DOM - access performance test:
< !DOCTYPE html PUBLIC ???-//W3C//DTD XHTML 1.0 Strict//EN???
???http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd??? >
< html xmlns=???http://www.w3.org/1999/xhtml??? >
< head >
< title > Performance Test < /title >
< /head >
< body >
< form id=???form1??? >
< input id=???i1??? value=???zero??? type=???text??? >
< /form >
< div id=???output??? > < /div >
< /body >
< script type=???application/x-javascript??? >
var i = 0;
var start1 = new Date().getTime();
divs = document.getElementsByTagName(???div??™);
for(i = 0; i < 80000; i++)
{
var d = divs[0];
}
var start2 = new Date().getTime();
var delta1 = start2 - start1;
document.getElementById(???output???).innerHTML = ???Time: ??? + delta1;
< /script >
< /html >
Safari for Mac OS X executes this script in 529 milliseconds, while Safari for iPhone takes 13,922
milliseconds.


Pages:
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248