TinyMCE Compressor Perl version 2.0.0

About

TinyMCE Compressor gzips all javascript files in TinyMCE to a single streamable file. This makes the overall download size 75% smaller and the number of requests will also be reduced. The overall initialisation time for TinyMCE will be reduced dramatically if you use this script.

The TinyMCE Perl compressor project page is at http://hacks.traveljury.com/perl_compressor/

The current release can always be downloaded from http://hacks.traveljury.com/perl_compressor/current.tar.gz

Installation

Here is a step by step list on how to install the GZip compressor.

  1. Use CPAN to install File::Spec, File::Slurp, Digest::MD5 and Compress::Zlib.
  2. Copy the tiny_mce_gzip.js and tiny_mce_gzip.pl to the tiny_mce directory. The same directory that contains the tiny_mce.js file.
  3. Create the sub directory 'cache' under your tiny_mce directory and give your web server permission to write to it, eg:
            cd /path/to/tinymce
            mkdir cache
            chown apache cache
            chmod u+rwx,og-rwx cache
            

    PLEASE NOTE: If you upgrade your Tiny MCE editor, you will need to clear out the cache directory.

  4. Remove the current script tag:
    <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
  5. Add the new new GZip script tag:
    <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce_gzip.js"></script>.
  6. Add the new GZip initialization call (see below) that will tell the compressor what to include in the output. This should be the sum of all themes, plugins and languages contained on page.

Running under mod_perl

You either need to set up your web server to execute tiny_mce_gzip.pl as a CGI script, or you can configure Apache to run it under mod_perl, which will greatly speed up the response.

To do this, you could use a configuration like this:

    <Location /tiny_mce/tiny_mce_gzip.pl>
        SetHandler perl-script
        PerlResponseHandler ModPerl::Registry
        PerlOptions +ParseHeaders
        Options +ExecCGI
        Order allow,deny
        Allow from all
    </Location>

Example of initialization

The example below will pack both themes and all plugins into one file/stream. Remove the things you don't need or add you custom plugins to the settings below. Remember that the tinyMCE_GZ.init call must be placed in it's own script tag.

    <script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce_gzip.js"></script>
    <script type="text/javascript">
        tinyMCE_GZ.init({
            plugins     : 'style,layer,...etc',
            themes      : 'simple,advanced',
            languages   : 'en',
            disk_cache  : true
        });
    </script>

    <!-- Needs to be seperate script tags! -->

    <script type="text/javascript">
        tinyMCE.init({
            .. your normal init ..
        });
    </script>

Troubleshooting

Visit the TinyMCE forum for help with the TinyMCE Gzip Compressor.

Changelog and Bugs

See the ChangeLog here : changelog.txt

Please report any bugs that you find to clint@traveljury.com

License notice

The perl part of this library has been written by Clinton Gormley (clint@traveljury.com).

The javascript part has been taken from the PHP compressor available at MoxieCode.

This library is under LGPL license but it uses the zlib library, which is free to use in commercial applications. (Read the zlib licence).