API DOCS

DOCS & TUTORIALS » API DOCS » xajax_core » xajax.inc.php » xajax » autoCompressJavascript

Function: autoCompressJavascript


function autoCompressJavascript($sJsFullFilename=NULL, $bAlways=false)

Parameters:

sJsFullFilename
(string) The relative path and name of the file to be compressed.

bAlways
(boolean) Compress the file, even if it already exists.


Examples

To compress the xajax javascript core use the following statement:

Code: php

 
$xajax->autoCompressJavaScript(null,true);
 



Call it right after $xajax->processRequest(); otherwise your script will compress xajax over and over again per request, thus slowing down your app.
Normally you don't have to recompile the xajax core, it's supposed to be solid right out of the box ;)

You can however use the autoCompress feature to compress your own javascript plugins. We recommend to compress your JS files if you'r writing your own xajax plugins. In your plugins folder name your files in this scheme:

myclass_uncompressed.js


Now compress the file:

Code: php

 
$xajax->autoCompressJavaScript('./xajax/xajax_plugins/response/myclass/myclass.js',true);
 


It's correct that we don't add '_uncomressed.js' in the filename - xajax adds it automatically.
In your plugin you can now include the compressed: 'myclass.js'.

 



XAJAX on SourceForge.net
Support this project Valid XHTML 1.0 Transitional