AJAX - The Complete Reference

(avery) #1

264 Part II: Developing an Ajax Library^


money. Even if it does cause a slight delay, the bandwidth savings can really add up for
high traffic sites. HTTP compression is certainly a good idea for improving a site’s speed,
but there are many other techniques that can be applied as well.

NNOT EOTE To implement HTTP compression on Apache use mod_gzip or deflate built-in. On IIS use a
commercial facility like httpZip.

Content Optimization


Another form of content reduction besides transparent HTTP compression is to directly
optimize the content. Reductions may be performed by hand or, more likely, by using tools.
Content optimization can be as simple as removing any unnecessary whitespace from
markup, CSS, and XML payloads. In the case of JavaScript, it is also possible to remove
whitespace, but ensure that semicolons have been used appropriately, or the byte shaving
might cause some problems. Visually, this kind of “crunching” looks a bit intimidating to
those who might view your source:

However, don’t assume that this presents much obfuscation benefit, as it is easily reversed
using a pretty printing program. We’ll discuss this again within the context of security in the
next chapter, but at this point our focus is byte-count reduction in favor of speed improvement.
Now let’s briefly discuss each form of optimization by type of content.

Markup Optimization
Typical page markup is either very tight, hand-crafted, and standards-focused, filled with
comments and formatting whitespace, or it is bulky, editor-generated markup with
excessive indenting, editor-specific comments often used as control structures, and even
Free download pdf