title: How to link to a gzipped javascript in an html document?
body: <p>I've seen a number of references to gzipping a javascript to save download time.  <em>But</em> I also see a number of warnings that certain browsers do not support this.</p>
  
  <p>I have two different methods at my disposal:</p>
  
  <ol>
  <li>use <code>mod_deflate</code> to make Apache compress JS/CSS files in a given directory through htaccess</li>
  <li>use <code>ob_start('gzhandler')</code> to compress a file and return it to the browser with the correct headers.</li>
  </ol>
  
  <p>The problems with method 1 are that not all browsers support mod_deflate, and I have no clue how to write the <code>.htaccess</code> file to be smart enough to adjust for this.</p>
  
  <p>The problem with method 2 is that there is no definitive answer about how to tell if a browser supports a gzipped script, or stylesheet, and that if it does what mime-type must be given as the content type in the header.</p>
  
  <p>I need some advice.  First, which method is more universally accepted by browsers?  Second, how do I decay using either method to provide the uncompressed backup script?  Third, would <code>&lt;script src="js/lib.js.gz" type="text/javascript"&gt;&lt;/script&gt;</code> work by itself?  (It obviously wouldn't decay.)</p>
  
  <p>For the record, I'm using PHP5 with mod_deflate and full gzip creation capabilities, and my doctype is xhtml strict.  Also, the javascript itself is compressed with YUI.  <strong>Edit:</strong>  I just went back and looked, but I have only Apache 1.3; I thought I had 2, so sorry for mentioning mod_deflate when I probably don't have it.</p>