Location: PHPKode > projects > BackendPro > user_guide/libraries/assets/js_compression.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>

<title>BackendPro User Guide : JS Compression</title>

<style type='text/css' media='all'>@import url('../../userguide.css');</style>
<link rel='stylesheet' type='text/css' media='all' href='../../userguide.css' />

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name='robots' content='all' /> 

</head>

<body>

<!-- START NAVIGATION -->
<div id="nav"><div id="nav_inner"></div></div>
<div id="nav2"><a name="top">&nbsp;</a></div>
<div id="masthead">
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td><h1>BackendPro User Guide Version 0.6.1</h1></td>
<td id="breadcrumb_right"><a href="../../contents.html">Table of Contents</a></td>
</tr>
</table>
</div>
<!-- END NAVIGATION -->

<!-- START BREADCRUMB -->
<table cellpadding="0" cellspacing="0" border="0" style="width:100%">
<tr>
<td id="breadcrumb">
<a href="http://www.kaydoo.co.uk/projects/backendpro">BackendPro Home</a> &nbsp;&#8250;&nbsp;
<a href="../../index.html">User Guide Home</a> &nbsp;&#8250;&nbsp;    
<a href="../assets.html">Asset Library</a> &nbsp;&#8250;&nbsp;  
JS Compression
</td>
<td id="searchbox"><form method="get" action="http://www.google.com/search"><input type="hidden" name="as_sitesearch" id="as_sitesearch" value="http://www.kaydoo.co.uk/backendpro/user_guide/" />Search User Guide&nbsp; <input type="text" class="input" style="width:200px;" name="q" id="q" size="31" maxlength="255" value="" />&nbsp;<input type="submit" class="submit" name="sa" value="Go" /></form></td>
</tr>

</table>
<!-- END BREADCRUMB -->

<br clear="all" />


<!-- START CONTENT -->
<div id="content">


<h1>JS Compression</h1>
<p>The <a href="../assets.html">Asset Library</a> comes with the ability to compress 
and optimise your JS code. The plugin called <a href="http://dean.edwards.name/packer/">/Packer/</a> is used to perform the actual 
optimisation.</p>
<p>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.</p>

<p class="important"><strong>Note</strong>: JS compression and optimisation does not alter your asset files 
on the server, it only effects the <kbd>cached</kbd> copies.</p>

<h2>Requirements</h2>
<ol>
	<li><strong>Turn on Asset Optimisation:</strong><br/>
	<p>You must turn on asset optimisation for the asset library, more details can be found on the <a href="asset_optimisation.html">Asset Optimisation</a> page.</p></li>

	<li><strong>Setup Packer:</strong><br/>
		<ol>
			<li>Download the latest version of the Packer plugin from the <a href="http://dean.edwards.name/download/#packer">downloads page</a>.</li>
			<li>Extract the zip contents to <dfn>modules/site/plugins/packer/</dfn>.</li>
			<li>Open the <dfn>modules/site/config/bep_assets.php</dfn> config file, find and set the following key (it is located near the bottom):
			<code>
			$config['packer']['path'] = BASEPATH . "../modules/site/plugins/packer/class.JavaScriptPacker.php4"; // PHP 4<br/>
			$config['packer']['path'] = BASEPATH . "../modules/site/plugins/packer/class.JavaScriptPacker.php"; // PHP 5
			</code></li>
		</ol>
	</li>
</ol>
<p>Now when a user visits the website the js files will be compressed and stored.</p>

<p class="important"><strong>Note</strong>: 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.</p>

</div>
<!-- END CONTENT -->

<div id="footer">
<p>
<a href="#top">Top of Page</a>&nbsp;&nbsp;&nbsp;&middot;&nbsp;&nbsp;
<a href="../../index.html">User Guide Home</a>
</p>
<p><a href="http://www.kaydoo.co.uk/projects/backendpro">BackendPro</a> &nbsp;&middot;&nbsp; Copyright &#169; 2009 &nbsp;&middot;&nbsp; <a href="http://www.kaydoo.co.uk">Adam Price</a></p>

</div>

</body>
</html>
Return current item: BackendPro