Automatic Optimization

First, use SpaceAgent to remove the comments, whitespace, and optional closing tags (see Figure 6.2).

Figure 6.2. SpaceAgent.
graphics/06fig02.gif

SpaceAgent, from Insider Software, automates the removal of excess whitespace (tabs, returns, and spaces) and can remove optional meta and closing tags, and even quotes. For this example, I turned off the optional quote removal for HTML and XHTML compliance. The result is 100,562 bytes, a savings of more than 27 percent. Although still quite large for a busy home page, this savings is significant. So this:

 <html>  <head> <title>Popular Mechanics</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <meta name="site" content="PM_Zone"> <meta name="Description" content=""> <meta name="Keywords" content=""> <meta name="department" content=""> <meta name="date" content=""> <meta name="display" content=""> <SCRIPT LANGUAGE="JavaScript"> function formHandler(form){ var URL = document.form.site.options[document.form.site.selectedIndex].value; window.location.href = URL; } </SCRIPT> </HEAD> <style type="text/css"> <!-- BODY { background-color: #000000; margin-left: 0px; margin-top: 0px; margin-width: 0px; graphics/ccc.gif margin-height: 0px;} A:link { color: #993333; font-family: Arial, Helvetica, sans-serif; font-size: 12pt;} 

Becomes this:

 <html><head><title>Popular Mechanics</title><meta name=Description content=""><meta graphics/ccc.gif name=Keywords content=""><SCRIPT LANGUAGE=JavaScript>function formHandler(form){var graphics/ccc.gif URL=document.form.site.options[document.form.site.selectedIndex].value;window.location. graphics/ccc.gif href=URL;}</SCRIPT><style type="text/css">  <!-- BODY { background-color: #000000; margin-left: 0px; margin-top: 0px; margin-width: 0px; graphics/ccc.gif margin-height: 0px;} A:link { color: #993333; font-family: Arial, Helvetica, sans-serif; font-size: 12pt;} 
NOTE: See also VSE Web Site Turbo for a Mac-only optimizer at http://www.vse-online.com.

Other than whitespace and redundant tag removal, most HTML optimizers do not optimize CSS or JavaScript effectively. You could save even more by optimizing the CSS and using shorthand hex color values and font shorthand properties. For example, #RRGGBB becomes #RGB, and font-size , font-family , etc., becomes font .

 



Speed Up Your Site[c] Web Site Optimization
Speed Up Your Site[c] Web Site Optimization
ISBN: 596515081
EAN: N/A
Year: 2005
Pages: 135

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net