Skip to content
eoghanmurray edited this page Mar 3, 2011 · 1 revision

Roll your own packed MochiKit file

Note: The customized download page can now be used instead of the process described here.

After your development is completed using the full MochiKit.js file, you want to replace MochiKit.js with a packed version containing the smallest number of modules required by your app. Start by replacing your MochiKit.js script line with only the modules you absolutely need:

- <script src="mochikit/MochiKit/MochiKit.js" type="text/javascript">
+ <script src="mochikit/MochiKit/Base.js" type="text/javascript">
+ <script src="mochikit/MochiKit/Async.js" type="text/javascript">
+ <script src="mochikit/MochiKit/DOM.js" type="text/javascript">
+ <script src="mochikit/MochiKit/Style.js" type="text/javascript">
+ <script src="mochikit/MochiKit/Signal.js" type="text/javascript">

After you've tested and whittled it down as far as you can, create your customized packed file as so:

> cd mochikit
> scripts/pack.py "Base" "Async" "DOM" "Style" "Signal" >../MochiKit4MyApp.js
> cd ..
> chmod 604 MochiKit4MyApp.js

and replace all your MochiKit script lines with the single line:

+ <script src="MochiKit4MyApp.js" type="text/javascript">

Finally, retest and release!

You'll need the Java Runtime Environment installed on your system (and the java command in your PATH), in addition to Python, to run scripts/pack.py.

Note: Only the official Sun Java currently works, so any OpenJDK, gcj or other Java implementations will probably break the packager. Try using update-java-alternatives (Ubuntu/Debian) or modifications of JAVA_HOME or the PATH variables to ensure the correct Java version being used. On Ubuntu you will need to use the official sun version sudo apt-get install sun-java6-jdk (and possibly uninstall openjdk-6).

Clone this wiki locally