[ka-Map-users] gzip-ing .js

Paul Spencer pspencer at dmsolutions.ca
Wed Mar 22 09:20:19 EST 2006


Brent,

thanks for this.  I've added it to ka-Map's getcjs.php function as  
per my earlier post.  This results in a significant reduction in file  
size ... from 170kb to about 22kb.  Just removing whitespace and  
comments is about a factor of 2 improvement (170 to 88kb) then  
gzipping reduces by a factor of 4!

Cheers

Paul

On 6-Mar-06, at 10:57 AM, Brent Pedersen wrote:

> hi, just saw this use of php that seems especially applicable to ka- 
> map javascript.
> you can get php to gzip .js (or .css) files for you. this seems to  
> be working pretty well. (see code below.) it gets it down to a  
> single request of 27K instead of 8 requests totalling > 130K.
>
> -brent
>
>
> <?php
> ob_start ("ob_gzhandler");
> header("Content-type: text/javascript; charset: UTF-8");
> header("Cache-Control: must-revalidate");
> $days = 30;
> $offset = 60 * 60 * 24 * $days;
> $ExpStr = "Expires: " .
> gmdate("D, d M Y H:i:s",
> time() + $offset) . " GMT";
> header($ExpStr);
>
> $files = array("DHTMLapi.js", "xhr.js", "jsExpander.js ",  
> "kaMap.js", "kaTool.js", "startUp.js", "extra.js","testExtents.js");
>
> foreach ($files as $fi){
>   print file_get_contents($fi);
> }
>
> ?>
>
> _______________________________________________
> ka-Map-users mailing list
> ka-Map-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/ka-map-users

+-----------------------------------------------------------------+
|Paul Spencer                           pspencer at dmsolutions.ca   |
+-----------------------------------------------------------------+
|Applications & Software Development                              |
|DM Solutions Group Inc                 http://www.dmsolutions.ca/|
+-----------------------------------------------------------------+






More information about the ka-Map-users mailing list