<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Omn1s</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/dev/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Omn1s"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/Special:Contributions/Omn1s"/>
	<updated>2026-09-03T10:55:30Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/dev/index.php?title=Javascript_FAQ&amp;diff=45661</id>
		<title>Javascript FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/dev/index.php?title=Javascript_FAQ&amp;diff=45661"/>
		<updated>2014-07-10T18:10:23Z</updated>

		<summary type="html">&lt;p&gt;Omn1s: /* Online resources: */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== What is JavaScript? ==&lt;br /&gt;
&lt;br /&gt;
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).&lt;br /&gt;
&lt;br /&gt;
If you have a spare 27 minutes and would like a quick background on JavaScript and it&#039;s origins, see this video from Douglas Crockford &#039;[http://www.youtube.com/watch?v=gz7KL7ZirZc JSeverywhere: Douglas Crockford - JavaScript, The World&#039;s Most Misunderstood Language]&#039;.&lt;br /&gt;
&lt;br /&gt;
== Where do I find general information about JavaScript? ==&lt;br /&gt;
&lt;br /&gt;
=== Online resources: ===&lt;br /&gt;
* [http://en.wikipedia.org/wiki/JavaScript JavaScript (Wikipedia)]&lt;br /&gt;
* [http://articles.sitepoint.com/category/javascript Sitepoint JavaScript tutorials]&lt;br /&gt;
&lt;br /&gt;
=== Books: ===&lt;br /&gt;
* [http://shop.oreilly.com/product/9780596517748.do JavaScript: The Good Parts] by Douglas Crockford&lt;br /&gt;
* [http://oreilly.com/catalog/9780596101992 JavaScript: The Definitive Guide, Fifth Edition] by David Flanagan - Really the ultimate reference guide (nearly 1000 pages).&lt;br /&gt;
* [http://www.sitepoint.com/books/jsant1/ The JavaScript Anthology: 101 Essential Tips, Tricks &amp;amp; Hacks] by James Edwards &amp;amp; Cameron Adams - Promotes accessible JavaScript solutions by following the principles of [[Progressive enhancement| progressive enhancement]] and [[Unobtrusive_Javascript| unobtrusive scripting]].&lt;br /&gt;
&lt;br /&gt;
== How is JavaScript used by Moodle? ==&lt;br /&gt;
&lt;br /&gt;
* See [https://docs.moodle.org/en/Category:Javascript Category:Javascript].&lt;br /&gt;
&lt;br /&gt;
== Where do I find more information about JavaScript in Moodle? ==&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript_guidelines|JavaScript Guidelines]] by Tim Hunt (work in progress)&lt;br /&gt;
* [http://moodle.org/mod/forum/discuss.php?d=106312 Use of JavaScript in Moodle] discussion in the General developer forum&lt;br /&gt;
&lt;br /&gt;
== What JavaScript library does Moodle use? ==&lt;br /&gt;
&lt;br /&gt;
=== Yahoo! User Interface Library (YUI) === &lt;br /&gt;
Moodle uses the Yahoo! User Interface Library (YUI).&lt;br /&gt;
&lt;br /&gt;
==== Online resources: ====&lt;br /&gt;
* [http://yuilibrary.com Yahoo! User Interface Library (YUI)]&lt;br /&gt;
* [[YUI]] in the Moodle documentation&lt;br /&gt;
&lt;br /&gt;
==== Books: ====&lt;br /&gt;
* [http://shop.oreilly.com/product/0636920013303.do YUI 3 Cookbook] by Evan Goer&lt;br /&gt;
* [http://shop.oreilly.com/product/0636920025245.do Maintainable JavaScript] by Nicholas C. Zakas&lt;br /&gt;
&lt;br /&gt;
==== How/Why was YUI chosen for Moodle? ====&lt;br /&gt;
&lt;br /&gt;
The decision was made in [http://moodle.org/mod/forum/discuss.php?d=48478 this thread in the General Developer Forum].&lt;br /&gt;
&lt;br /&gt;
Since this decision was made, it&#039;s continued use has been questioned several times. Some of the main reasons for it&#039;s use include:&lt;br /&gt;
&lt;br /&gt;
* good documentation;&lt;br /&gt;
* an active developer community;&lt;br /&gt;
* code modularity;&lt;br /&gt;
* a powerful loader system separating loading from execution and adding dependency resolution; and&lt;br /&gt;
* sandboxing of code as standard.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
== What other JavaScript libraries are around? ==&lt;br /&gt;
&lt;br /&gt;
=== jQuery ===&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
It is possible to use jQuery in Moodle, but it is not recommended.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;JavaScript written using jQuery will not be accepted within core Moodle code.&#039;&#039;&#039; However since Moodle 2.5 jQuery and jQuery UI libraries are included in default installation, these are intended to be used in add-ons only. See [[jQuery]] page for more information.&lt;br /&gt;
&lt;br /&gt;
==== Can&#039;t we switch to jQuery in core?====&lt;br /&gt;
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:&lt;br /&gt;
&lt;br /&gt;
* jQuery does not encourage sandboxing of code&lt;br /&gt;
* jQuery does not have a decent modular system - plugins typically exist in the global $ namespace (and due to lack of sandboxing), this means that:&lt;br /&gt;
** they can be modified after loading so other modules on the same page could modify a library function; and as a result&lt;br /&gt;
** it is possible for jQuery to overwrite itself and break your page&lt;br /&gt;
* jQuery does not have a loading system. You are typically expected to use the &amp;lt;script&amp;gt; tag which:&lt;br /&gt;
** can be inefficient&lt;br /&gt;
** means that your code is executed as soon as it loads;&lt;br /&gt;
*** which means that load order is often very significant&lt;br /&gt;
** has mixed browser support with some of it&#039;s advanced features;&lt;br /&gt;
** makes it difficult to make use of a combo loading system to load JS modules.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Whilst these reasons may not seem very important as they&#039;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):&lt;br /&gt;
&lt;br /&gt;
* a number of Moodle-specific YUI modules exist to encourage re-use of user interface components and functionality:&lt;br /&gt;
** so we need dependency management;&lt;br /&gt;
** and to ensure that load order of components does not matter;&lt;br /&gt;
** and that multiple uses of the same JS code does not break former or subsequent uses by it&#039;s mere inclusion.&lt;br /&gt;
* 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;&lt;br /&gt;
* 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 &#039;&#039;features&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
==== Online resources: ====&lt;br /&gt;
* [http://jquery.com/ jQuery] &lt;br /&gt;
* [http://visualjquery.com Visual jQuery]&lt;br /&gt;
* [http://jqueryfordesigners.com jQuery for Designers]&lt;br /&gt;
&lt;br /&gt;
==== Books: ====&lt;br /&gt;
* [http://www.manning.com/bibeault/ jQuery in Action] by Bear Bibeault and Yehuda Katz&lt;br /&gt;
* [http://www.packtpub.com/jQuery/book Learning jQuery] by Karl Swedberg and Jonathan Chaffer&lt;br /&gt;
* [http://www.packtpub.com/jquery-reference-guide-Open-Source/book jQuery Reference Guide] by Jonathan Chaffer and Karl Swedberg&lt;br /&gt;
&lt;br /&gt;
== What does AJAX mean? ==&lt;br /&gt;
AJAX means &amp;quot;Asynchronous JavaScript and XML&amp;quot;. It is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
See [http://en.wikipedia.org/wiki/Ajax_(programming) AJAX (Wikipedia)] for general information and [[AJAX]] for information on AJAX and Moodle.&lt;br /&gt;
&lt;br /&gt;
See also [[Firebug#Debugging AJAX_with_Firebug|Firebug &amp;gt; Debugging AJAX with Firebug]].&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Javascript and YUI 3 FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
[[Category:Javascript]]&lt;br /&gt;
[[Category:AJAX]]&lt;/div&gt;</summary>
		<author><name>Omn1s</name></author>
	</entry>
</feed>