1. emeyer
  2. Newbies area
  3. Friday, 10 April 2009
  4.  Subscribe via email
Wow, my prototype site really speeded up with 4.0! thank you!

I made a small modification to further improve speed: compressing the compnent's javascript file. For this, one can compress it in advance, but that requires custom mime types, and the propcessor load is so low, it's easier to do it on the fily. The server must have gzip compression available in the system (which can be picked up from Joomla global config, but Joomla only compresses html files).

Compression reduced the file from 32KB to 5KB. I tried packing it beforehand but it didn't make any diference, gzip is pretty fantastic these days. The code change is simple:

1: Add the following to the top of components/com_comment/joscomment/jscripts/client.js and save it as client.php in the same directory:

<?php
ob_start ("ob_gzhandler");
header("Content-type: text/javascript");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>


2. Find the reference to client.js in components/com_comment/joscomment/jscript.php and change it to client.php.

That's it. It threw an IE7 error in 3.26 for one of the http functions but worked fine in 4.0. I'm looking into doing the same for an external jquery library component and combining the pieces into one file.

The files are arriving with jquery in the head. I haven't looked at that yet, but already the size is 27KB less.
Responses (3)


There are %s replies to this question. If you want to see them you need a valid subscription.
If you have a valid subscription, please login now.
Visit store now
Powered by EasyDiscuss for Joomla!