JS Compression
The Asset Library comes with the ability to compress and optimise your JS code. The plugin called /Packer/ is used to perform the actual optimisation.
That big advantage of running js compression on your asset files is it means they will be smaller thus meaning quicker to download for your users.
Note: JS compression and optimisation does not alter your asset files on the server, it only effects the cached copies.
Requirements
- Turn on Asset Optimisation:
You must turn on asset optimisation for the asset library, more details can be found on the Asset Optimisation page.
- Setup Packer:
- Download the latest version of the Packer plugin from the downloads page.
- Extract the zip contents to modules/site/plugins/packer/.
- Open the modules/site/config/bep_assets.php config file, find and set the following key (it is located near the bottom):
$config['packer']['path'] = BASEPATH . "../modules/site/plugins/packer/class.JavaScriptPacker.php4"; // PHP 4
$config['packer']['path'] = BASEPATH . "../modules/site/plugins/packer/class.JavaScriptPacker.php"; // PHP 5
Now when a user visits the website the js files will be compressed and stored.
Note: The JS packer only works on JS which has not yet been minimised/packed. If you run it on packed JS it tends to fail.