Using MochiKit with other libraries
MochiKit exports a large number of convenience functions to the global namespace, possibly colliding with other functions with the same name in other JavaScript libraries. Typically, the $ and $$ functions cause collitions with libraries such as jQuery or Prototype. These collisions can be handled in a number of ways, some which are described here.
Regardless of which alternative is used below, all functions from MochiKit will always be available through the fully qualified names (e.g. MochiKit.Base.update).
1. Using MochiKit functions
If your code depends on the MochiKit versions of ambiguous functions, the MochiKit library should be the last library included on the page. This will ensure that any ambiguous functions are overwritten with the version from MochiKit.
<html> <head> <script src="other/library.js"></script> <script src="MochiKit.js"></script> </head>
2. Using other library functions
If your code depends on the other library version of ambiguous functions, the MochiKit library could be the first library included on the page. This will ensure that any ambiguous functions are overwritten with the version from the other library.
<html> <head> <script src="MochiKit.js"></script> <script src="other/library.js"></script> </head>
3. Maximum Compability
If you want to achieve maximum compability with other libraries and tools, it is possible to skip exporting function names from MochiKit altogether.
<html>
<head>
<script type="text/javascript">MochiKit = {__export__: false};</script>
<script src="MochiKit.js"></script>
</head>
