- 7 What does AJAX mean?
- 8 See also
Yahoo! User Interface Library (YUI)
Moodle uses the Yahoo! User Interface Library (YUI).
How/Why was YUI chosen for Moodle?
The decision was made in this thread in the General Developer Forum.
Since this decision was made, it's continued use has been questioned several times. Some of the main reasons for it's use include:
- good documentation;
- an active developer community;
- code modularity;
- a powerful loader system separating loading from execution and adding dependency resolution; and
- sandboxing of code as standard.
Most other major libraries do not offer many of these major features including the powerful loader and dependency system which are particularly useful in the modular environment of Moodle.
Can't we switch to jQuery in core?
Although jQuery is very popular with many developers and has stood out in recent years, there are a number of key infrastructure reasons which have the potential to cause major issues in a system like Moodle. As an example, some of these core infrastructure-type reasons include:
- jQuery does not encourage sandboxing of code
- jQuery does not have a decent modular system - plugins typically exist in the global $ namespace (and due to lack of sandboxing), this means that:
- they can be modified after loading so other modules on the same page could modify a library function; and as a result
- it is possible for jQuery to overwrite itself and break your page
- jQuery does not have a loading system. You are typically expected to use the <script> tag which:
- can be inefficient
- means that your code is executed as soon as it loads;
- which means that load order is often very significant
- has mixed browser support with some of it's advanced features;
- makes it difficult to make use of a combo loading system to load JS modules.
Whilst these reasons may not seem very important as they're just nuts and bolts JS issues, when considered in combination with the modularity of Moodle itself they make a lot more sense. Bearing in mind that Moodle encourages use of contributed plugins (blocks, modules, question types, etc):
- a number of Moodle-specific YUI modules exist to encourage re-use of user interface components and functionality:
- so we need dependency management;
- and to ensure that load order of components does not matter;
- and that multiple uses of the same JS code does not break former or subsequent uses by it's mere inclusion.
- with the availability of contributed plugins for moodle we need to ensure that modules do not interfere with, or have negative effects on, one another;
- with the potential number of non-core plugins, sandboxing of that code is important to prevent inadvertent issues caused by individual plugins (e.g. changing core library code to add features).
- jQuery in Action by Bear Bibeault and Yehuda Katz
- Learning jQuery by Karl Swedberg and Jonathan Chaffer
- jQuery Reference Guide by Jonathan Chaffer and Karl Swedberg
What does AJAX mean?
See also Firebug > Debugging AJAX with Firebug.