Document Information

Last modified:
2007/05/31 18:16 by thron7

Compress qooxdoo.js without mod_deflate

This explains how to enable a gzipped qooxdoo.js without having this possibility directly built in to your webserver.

If you have php at the server, you can write in your html file:

<script type="text/javascript" src="<<path>>/qooxdoo.php"></script>

Then you create a file called qooxdoo.php with this content:

<?php
   /**
   * @author     Oliver Vogel <o.vogel@muv.com>
   * @since      05.03.2006
   */
   $encodings = array();
   if (isset($_SERVER['HTTP_ACCEPT_ENCODING']))
   {
       // Get all available encodings
       $encodings = explode(',', strtolower(preg_replace("/s+/", "", $_SERVER['HTTP_ACCEPT_ENCODING'])));
         // Check for gzip header
       if (in_array('gzip', $encodings))
       {
           // found: send the zip-ed file
           header("Content-Encoding: gzip");
           echo file_get_contents(getenv('DOCUMENT_ROOT') . '<<path>>/qooxdoo.js.gz');
           die;
       }
   }
 
   // Encoding not found or gzip not accepted -> send "normal" file
   echo file_get_contents(getenv('DOCUMENT_ROOT') . '<<path>>/qooxdoo.js');
   die;
?>

This page checks if the browser supports gzip. If this is true, the server sends the gzip file to the client. This solution needs no gzip-support at the server-side!

Also, if you are writing your own webserver it is trivial to include this feature directly.

I know, it is NOT JavaScript but maybe it is a good idea to add this to the qooxdoo distribution (and it may be a good idea if one with Python or Perl or other experience ports this script to another server-side programming language).

Contributed by Oliver Vogel, here.

Information

Last modified:
2007/05/31 18:16 by thron7

Account

Not logged in

 
 

Job Offers

To further improve qooxdoo we are seeking javascript developers. Read more...

Rich Ajax Platform (RAP)

RAP uses qooxdoo, Java and the Eclipse development model to build rich web applications. Read more...

qooxdoo Web Toolkit (QWT)

Similar to GWT this framework allows to create impressive qooxdoo applications just using Java. Read more...

Pustefix

Pustefix is a MVC-based web application framework using Java and XML/XSLT. Read more...

 
SourceForge.net Logo

Bad Behavior has blocked 0 potential spam attempts in the last 7 days.