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

Richard Wagner

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


??‘
??‘
Chapter 9: Bandwidth and Performance Optimizations
213
Dojo ShrinkSafe ( alex.dojotoolkit.org/shrinksafe ) optimizes and crunches local variable
names to achieve greater compression ratios.
Dean Edwards ??™ s Packer ( dean.edwards.name/packer ) is an aggressive optimizer that
achieves high compression ratios.
Deciding which of these options to use should depend on your specific needs and the nature of your
source code. I recommend starting on the safe side and moving up as needed.
If you decide to use one of these optimizers, make sure you use semicolons to end your lines in your
source code. Besides being good programming practice, most optimizers need them to accurately
remove excess whitespace.
Additionally, while Packer requires semicolons, Dojo ShrinkSafe does not require them and will actually
insert missing semicolons for you. So you can pre - process a JavaScript file through ShrinkSafe before
using it in a semicolon requiring compressor like Packer.
To demonstrate the compression ratios that you can achieve, I ran the iUI.js JavaScript library file
through several of these optimizing tools. Table 9 - 1 displays the results.
??‘
??‘
Table 9 - 1: Benchmark of Compression of i UI .js File
Compressor
JavaScript compression
(bytes)
With gzip compression
(bytes)
No compression 100 % (11284) 26 % (2879)
JSMin 65 % (7326) 21 % (2403)
Dojo ShrinkSafe 58 % (6594) 21 % (2349)
YUI Compressor 64 % (7211) 21 % (2377)
YUI Compressor (w/Munged) 46 % (5199) 18 % (2012)
YUI Compressor (w/Preserve All
Semicolons)
64 % (7277) 21 % (2389)
YUI Compressor (w/Munged and
Preserve All Semicolons)
47 % (5265) 18 % (2020)
One final option worth considering is a PHP - based open source project called Minify.


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