×

Notice

The forum is in read only mode.
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: compressing jscript files?

compressing jscript files? 15 years 8 months ago #3567

  • emeyer
  • emeyer's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 25
  • Thank you received: 0
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.

compressing jscript files? 15 years 8 months ago #3573

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
That sounds pretty interesting! But why not deliver both javascript files. The compressed one and the uncompressed one and we can leave the option to the user which one to use?

I don't know if you saw this, but right now with joomlacomment4.0 alpha3 we are loading a small javascript for the ads. If you remove it, then your site must become more faster :) In the next version I will remove it.
The idea was, that if I see the web site I could turn the google ads on, but I don't think this is going to be nice for the users. And I want that you all enjoy joomlacomment.

However, if you are happy with the product, with the support and you wish to help the project I will be happy to see you registered as publisher :)

compressing jscript files? 15 years 8 months ago #3580

  • emeyer
  • emeyer's Avatar Topic Author
  • Offline
  • Junior Boarder
  • Junior Boarder
  • Posts: 25
  • Thank you received: 0
Well, I'm still working through the 1.5 template overrides...meanwhile, I merged the comment .css into the main template css file which reduces http fetches and gets better compression. But I had to modify one of your core files to stop the css push into the header.

The script for the ads is showing up in the print window too. I'm not sure that's desirable.

compressing jscript files? 15 years 8 months ago #3585

  • Daniel Dimitrov
  • Daniel Dimitrov's Avatar
  • Offline
  • Administrator
  • Administrator
  • Posts: 9618
  • Karma: 155
  • Thank you received: 1081
Well, you can always set display:none for the ads in the print version?
  • Page:
  • 1
Time to create page: 0.144 seconds