How to Super Compress Mootools |
|
| Written by Rick Winkler | |
| Sunday, 16 March 2008 | |
|
Mootools can provide a number of great enhancements to your site. Mootools.net provides an excellent downloader that allows you to obtain a custom package with only the components you need. By default, the downloader will compress the file using the YUI Compressor. This compressor does a pretty good job, but we can do better. 2. Head over to Dojo ShrinkSafe. Browse to the freshly downloaded Mootools file, select it, and then click the “shrink em!” button. Save the new file. 3. Head over to Dean Edward’s Packer. Open the file saved from Dojo ShrinkSafe in a text editor. Copy and paste the contents of that file into Packer. Select the “Base62 encode” and “Shrink variables” options and click “Pack”. Copy the output to a new file and save. You now have a super compressed Mootools script. By selecting all components and using the default YUI compressor yields a file that is 66,079B. Using the above method yields a file that is 40,189B, which is almost a 40% improvement. If you have followed other articles involving Joomla and Mootools, you can use this process to generate an optimized mootools.js file. You can also pretty much run any javascript code through this process. I did run into one third party script which encountered errors when used, and those errors where caused by poor coding of the script. Fixing the errors in the non compressed script solved the problem. |
