Minify (removal of all comments and extra whitespace)

pkej - February 28, 2008 - 13:47
Project:Javascript Aggregator
Version:5.x-1.2
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:won't fix
Description

Would it be possible to include this class (or letting people use download it and let the module use it if available) http://joliclic.free.fr/php/javascript-packer/en/

In my own code I've added include_once at the top of the module and below the line:

        $contents .= ";\n/* AGGREGATED JS FILE: $scripts_js_file */\n".$data."\n";

I added the following:

$packer = new JavaScriptPacker($contents, 'Normal', true, false);
$contents = $packer->pack();

UI wise it could be an option in the performance page which is greyed out if the packer class isn't downloaded, and when it is downloaded you could elect to use the class on the final file before saving (like I placed it after the current versions system).

AttachmentSize
packer.php-1.0.zip16.88 KB

#1

pkej - February 29, 2008 - 12:40
Title:Minify (pack) javascript (to make yslow love the cached scripts)» Minify (removal of all comments and extra whitespace)
Status:active» active (needs more info)

Ah, never mind using this one. It creates lots of javascript errors b/c uncompressed scripts wont find the data they need. Of course, if a similar class without the packing, just with proper removal of whitespace, that would be a nice addition.

#2

derjochenmeyer - February 29, 2008 - 12:46

the aggregator already removes large comments... i think that without packing the files, the space for improvement is in the range of less than 1% ...

#3

moshe weitzman - March 25, 2008 - 06:04

core js aggregator for D6 had to roll back its packer because of incomptibilities with some scripts. i suggest sticking to just aggregation.

#4

pkej - April 18, 2008 - 12:53
Status:active (needs more info)» won't fix

I've learned that the hardway.

Also, I saw that my score jumped to 80, some pages 90, on http://www.samipath.com anyway, so I'm happy with that.

#5

chirale - July 11, 2008 - 09:43

There is a JSMin based solution:

http://drupal.org/node/251140

 
 

Drupal is a registered trademark of Dries Buytaert.