PART II
Chapter 6: Networking Considerations 265
redundant or needless markup or code. Neither case is optimal for delivery. The following
tips are safe and easy ways to decrease file size:
- Remove whitespace in markup wherever possible.
In general, multiple whitespace characters (spaces, tabs, newlines) can safely be
eliminated, but of course avoid changing data inside,
- Remove comments.
Almost all comments, except for client-side conditional comments for IE and
doctype statements, can be safely removed. - Remap color values to their smallest forms.
Rather than using all hex values or all color names, use whichever form is shortest
in each particular case. For example, a color attribute value like #ff0000 could be
replaced with red, while lightgoldenrodyellow would become #FAFAD2. - Remap character entities to their smallest forms.
As with color substitution, substituting a numeric entity for a longer alpha-oriented
entity can save bytes. For example, È would become È. Occasionally,
this works in reverse as well: ð saves a byte if referenced as ð. However,
this is not quite as safe, and the savings are limited. - Remove useless tags.
Some “junk” markup, such as tags applied multiple times or certain <meta> tags
used as advertisements for editors, can safely be eliminated from documents.
Questionable Markup Optimization Techniques
While the first five techniques can result in significant savings on the order of 10 to 15
percent of markup size, many tools and developers looking for maximum delivery
compression employ some questionable techniques, including:
- Removing quotes surrounding attributes
- Removing implicit/default attributes like type="text/javascript" for