Compress your Framework
Now that you have your Framework create in yourlibrary.js, you might want to save some space using a compressor. I will present two famous one that I used before. First step is to create a compressor folder.
Framework tree so far:
git clone https://github.com/rgrove/jsmin-php
Open your build.php file and add the highlighted rows:
<?php // include the packager library require dirname(__FILE__) . '/packager/packager.php'; // include the compressor library require dirname(__FILE__) . '/compressor/jsmin.php'; // List of Package needed $packages = array('mootools-core', 'mootools-more', 'yourLibrary'); // Register all the packages needed to create your Framework $pkg = new Packager($packages); // List of Component needed for Core. These are just examples, you might need more $core = array('Core/Core', 'Core/Array', 'Core/String'); // List of Component needed for More. These are just examples, you might need more $more = array('More/Fx.Accordion', 'More/URI', 'More/Fx.Scroll'); // List of Component needed for More $yourlibrary = array('yourLibrary/MyFirstClass', 'yourLibrary/MySecondClass'); // List of all Component needed $components = array_merge($core, $more, $yourlibrary); // Create the yourlibrary.js file $pkg->write_from_components('yourlibrary.js', $components); // create a compressed version of yourlibrary.js file_put_contents('yourlibrary_compressed.js', JSMin::minify(file_get_contents('yourlibrary.js'))); ?>
Go get the latest version here: https://github.com/yui/yuicompressor/blob/master/build/ and copy it inside the compressor folder.
Usage: java -jar yuicompressor-x.y.z.jar [options] [inputfile]
We are now done with this tutorials in 5 parts. I hope it was helpful. Any questions, comments let me know.