MoxieCompressor makes your site or product fast!
Spocke We have been working on project for minification, concatenation and gzip compresson of JavaScript and CSS files for a while. It started as a part of our commercial products but it has over time matured into it’s own project.
Since we do a lot of JavaScript development and the code base tends to be very large overtime we where forced to come up with solutions to reduce the download size for the users. We started this as a project for TinyMCE and there is a compression package available for that product but that was just the seed for these classes and we will in time replace the TinyMCE compression package with this one.
We have by intention not made it possible to for example send in the files you want to compress from the page level in a query string. This is to make the script more secure and it wouldn’t be that nice if there are like 30 scripts to compress. You can always make your own simple switch statement in the compression page to send out different sets of files depending on input.
Below is an example of a usage scenario it basically compresses a few files together into one request it will also cache the file to disk to reduce the server workload. The compression ratio is about 70% depending on content so it really makes a difference on bandwidth and overall traffic from the client to the server.
// Setup compressor
$compressor = new Moxiecode_JSCompressor(array(
'expires_offset' => '10d', // 10 days
'disk_cache' => true,
'cache_dir' => '_cache',
'gzip_compress' => true,
'remove_whitespace' => false,
'charset' => 'UTF-8',
'patch_ie' => true // Fixes an IE bug
));
// Add files
$compressor->addFile("jquery.js");
$compressor->addFile("thickbox.js");
$compressor->addFile("syntax/shCore.js");
$compressor->addFile("syntax/shBrushPhp.js");
$compressor->addFile("syntax/shBrushJScript.js");
$compressor->addFile("functions.js");
// Output minified and gzipped contents
$compressor->compress();
So if you haven’t compressed your contents before we recommend that you give it a try since it will improve your clients user experience with a more fast loading site or system.
You can download the package and find more details about this project at moxieforge.net
Posted in Development
April 15th, 2008 at 20:25
Very nice, gonna give this one a spin
In the documentation I read that CSS is included via script tag (with type set to text/javascript). Think you’ve got a typo there, or am I overlooking something?
Regards,
Bram.
April 15th, 2008 at 21:14
Thanks for pointing this out. I’ve fixed the documentation.
April 21st, 2008 at 08:47
hi !
TinyMCE is really a great great project ! i just discovered it now ! damn you could do any dark futur to the online-microsoft word processor !
well, i have just 2 questions :
1.
which is the code highlighter you use in this blog ? it didn’t reference in your header html
2.
is it possible to integrated a syntaxe highlighter (with language choice) in TinyMCE ?
by advance, i thank you for read me and (i hope) answer me (here or by mt personal email).
again,
great project, great aim, grat pupose, great man ! (i hope you’re a great account bank too now!! because your project is free)
have a good day.
April 21st, 2008 at 13:47
1. We have it in the footer we use dp.syntaxhighlighter then we loop though all pre tags with the class js to bind it.
2. Yes, use pre elements then add the class js for example and match on that on the presentation side.