Firefox PHP

Module: Compress Javascript using Yahoo's YUI Compressor

Posted by Maurice Makaay 
All files from this thread

File Name File Size   Posted by Date  
compress_yui-1.0.4.tar.gz 795.2 KB open | download Maurice Makaay 03/13/2009 Read message
compress_yui-1.0.4.zip 796.4 KB open | download Maurice Makaay 03/13/2009 Read message
compress_yui_css.tar.gz 1.7 KB open | download sailord 09/08/2009 Read message
Module: Compress Javascript using Yahoo's YUI Compressor
June 03, 2008 02:48PM
This module compresses the Phorum Javascript code using Yahoo's excellent YUI Compressor. The JavaScript code can be compressed to less than 50% of its original size. This reduces bandwidth usage and speeds up the JavaScript code. This module needs java >= 1.4 on the server to function.

For the YUI Compressor license, see yuicompressor.license.txt in the package or go to
[developer.yahoo.com]

Troubleshooting:

If anything goes wrong during the compression process, the module will write out the error(s) at the start of the JavaScript output. To see them, open [yoursite.example.com] in your browser.

Opening the javascript.php directly in your browser would also be the way to check if the compression was successful. If it was, then the output will show a message that the javascript was compressed by yuicompressor and all code will be reduced to one very long and unreadable line.

Changelog:
2008-07-23 v1.0.4

   - Fixed a bug in the error output that is written to the start of
     the javascript.php in case the yuicompressor call fails.
     The error output was not correctly formatted as a javascript comment,
     causing a syntax error in the javascript.

2008-07-23 v1.0.3

   - Upgraded YUI compressor to version 2.4.2.

2008-06-08 v1.0.2

   - The settings screen now attempts to find the java program in the
     system's search path. The provided information on the settings
     screen will change, based on the outcome.

   - Added code to let Phorum rebuild the javascript cache if this module
     is enabled or if the module code changes.

2008-06-02 v1.0.1

   - Use full path to the compressor jar file. On some installs, the
     shell will be started in / instead of the Phorum directory.

2008-05-25 v1.0.0

   - Initial release.


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce



Edited 4 time(s). Last edit at 03/13/2009 11:32PM by Maurice Makaay.
Attachments:
open | download - compress_yui-1.0.4.tar.gz (795.2 KB)
open | download - compress_yui-1.0.4.zip (796.4 KB)
Re: Module: Compress Javascript using Yahoo's YUI Compressor
March 13, 2009 11:40PM
I released version 1.0.4 of the code. I this release, I renamed the module from compress_javascript to compress_yui, to open up the road for other compression methods to have their own module.

In this version, I fixed a problem that caused the resulting javascript to be broken when yuicompressor could not be executed for some reason. When the execution fails, then the module writes the error output to the start of the javascript.php output as a javascript comment block. This way, the admin can check the error in that output. The problem was that the comment block was not formatted correctly, resulting in a javascript syntax error.

So for the ones that have run an earlier version of this module and for which javascripts stopped working, yuicompressor could not correctly be executed. With this version, the javascript will keep working (but of course, no compression is done, making running the module rather senseless).


Maurice Makaay
Phorum Development Team
my blog linkedin profile secret sauce
Re: Module: Compress Javascript using Yahoo's YUI Compressor
September 08, 2009 12:50AM
Nice module. YUI compressor reduced the size of my javascript from 150 KB to 100 KB.
I modified this module a little for myself to compress CSS files too. The changes are in attahment
Attachments:
open | download - compress_yui_css.tar.gz (1.7 KB)
Sorry, only registered users may post in this forum.

Click here to login