Javascript FAQ
What is JavaScript?
JavaScript is a scripting language widely used for client-side web development. It is also known by a number of other names including ECMAScript, and JScript (these are all the same thing but exist due to issues over the licensing of these names).
If you have a spare 27 minutes and would like a quick background on JavaScript and it's origins, see this video from Douglas Crockford 'JSeverywhere: Douglas Crockford - JavaScript, The World's Most Misunderstood Language'.
Where do I find general information about JavaScript?
Online resources:
Books:
- JavaScript: The Good Parts by Douglas Crockford
- JavaScript: The Definitive Guide, Fifth Edition by David Flanagan - Really the ultimate reference guide (nearly 1000 pages).
- The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks by James Edwards & Cameron Adams - Promotes accessible JavaScript solutions by following the principles of progressive enhancement and unobtrusive scripting.
How is JavaScript used by Moodle?
- See Category:Javascript.
Where do I find more information about JavaScript in Moodle?
- JavaScript Guidelines by Tim Hunt (work in progress)
- Use of JavaScript in Moodle discussion in the General developer forum
What JavaScript library does Moodle use?
JQuery
As of Moodle 2.9, jQuery is the preferred javascript library. Most of the code is still using YUI though as we are only beginning to transition to jQuery.
Online resources:
- jQuery in Moodle
- jQuery
- Visual jQuery
- jQuery for Designers
Yahoo! User Interface Library (YUI)
Until Moodle 2.9, the Yahoo! User Interface Library (YUI) was the preferred javascript library. From Moodle 2.9 onwards, jQuery is the preferred javascript library.
Online resources:
- JQuery
- jQuery in the Moodle documentation
- Yahoo! User Interface Library (YUI)
- YUI in the Moodle documentation
Books:
- Writing Modular Javascript
- JQuery Enlightenment
- YUI 3 Cookbook by Evan Goer
- Maintainable JavaScript by Nicholas C. Zakas
Why are we moving away from YUI ?
The decision to begin the transition from YUI to JQuery was made here:
https://tracker.moodle.org/browse/MDL-47036
This is in response to Yahoos announcement that they will be ceasing all further development on YUI (although it is still maintained). http://yahooeng.tumblr.com/post/96098168666/important-announcement-regarding-yui
jQuery is another popular JavaScript library, used among others by Drupal, Joomla and WordPress. It is probably the most widely known JavaScript library at present.
As of Moodle 2.9 it is the recommended Javascript library to use with Moodle. See jQuery page for more information.
What does AJAX mean?
AJAX means "Asynchronous JavaScript and XML". It is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications. Although XML is included in the acronym, AJAX is not a single technology but a group of technologies. In reality with modern JS, this tends to be JSON which is much more lightweight and easy to produce in PHP than XML.
See AJAX (Wikipedia) for general information and AJAX for information on AJAX and Moodle.
See also Firebug > Debugging AJAX with Firebug.