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

Richard Wagner

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

Therefore, with that idea in mind, several options are available to compress
files and/or JavaScript code on the fly on the server.
Gzip File Compression
Mobile Safari provides support for gzip compression, a compression option offered by many Web
servers. Using gzip compression, you can reduce the size of HTML, CSS, and JavaScript files and
reduce the total download size by up to 4 to 5 times. However, because Mobile Safari must uncompress
the resources when it receives them, be sure to test to ensure that this overhead does not eliminate the
benefits gained.
To turn on gzip compression in PHP, use the following code:
< ?php
ob_start(???ob_gzhandler???);
? >
< html >
< body >
< p > This page has been compressed. < /p >
< /body >
< /html >
JavaScript Code Compression
In addition to reducing the total file size of your Web site, another technique is to focus on JavaScript
code. These compression strategies go far beyond the manual coding techniques described in this
chapter and seek to compress and minify ??” remove all unnecessary characters ??” your JavaScript
code. In fact, using these automated solutions, you can potentially reduce the size of your scripts by
30 ??“ 40 percent.
There are a variety of open source solutions that you turn to that tend to take two different approaches.


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