Before ob_gzhandler() actually sends compressed data, it determines what type of content encoding the browser will accept ("gzip", "deflate" or none at all) and will return its output accordingly.
>From http://uk.php.net/ob_gzhandler On Aug 15, 2:33 pm, xavier <[EMAIL PROTECTED]> wrote: > This means that : > 1) you assume all clients are able to deal with compressed pages > 2) your server is going to compress it for each visitor. > 3) the headers might or might not be properly dealing with its type. > > With mod_rewrite, they are nice tricks to have a compressed file and > serve it instead of the normal file if needed. > > Have you tried compressing the js file and send it instead of the file > without using mod_compress/mod_rewrite ? > > X+ > > On Aug 15, 11:08 am, Stephan Beal <[EMAIL PROTECTED]> wrote: > > > Hi, all! > > > i'm working on re-designing the web site for my mother's company, > > which was horribly neglected/abused by the previous webmaster, and i > > came across an interesting problem... > > > A part of the refactoring is to use jQuery for parts of the site. > > However, since all of the pages use the same site layout template > > (which includes the headers/script tags) yet most of the site won't > > actually use the JS features, i wanted to make the jQ download as tiny > > as possible. > > > Unfortunately, i don't have admin rights on my server so i cannot > > activate mod_gzip/mod_deflate to gzip the stuff on the fly. But here's > > an easy workaround... > > > Create a PHP file called jquery.php: > > > <?php > > ob_start( 'ob_gzhandler' ); > > echo join('',file('jquery-1.1.3.1.pack.js')); > > ob_end_flush(); > > ?> > > > Now, in the main site layout template i have: > > > <script type='text/javascript' src='/include/js/jquery.php'></script> > > > Firebug confirms that the jQ transfer is then 12k, which is tolerable > > for my purposes. > > > It would be only a tiny amount of extra work to integrate the PHP port > > of Dean Edwards' packer, such that the packing is done each time > > jquery.php is called, but that seems like overkill to me. > > > This approach could just as easily be used to combine all required JS > > scripts on the fly (just be sure to insert a ';' after each one to > > accommodate scripts which don't have them), then gzip them, to help > > reduce the overall download overhead.