Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Javascript FAQ: Difference between revisions

From MoodleDocs
(Created page with "== What is JavaScript? == JavaScript is a scripting language widely used for client-side web development. == Where do I find general information about JavaScript? == === Onlin...")
 
(28 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== What is JavaScript? ==
== What is JavaScript? ==


JavaScript is a scripting language widely used for client-side web development.
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 '[http://www.youtube.com/watch?v=gz7KL7ZirZc JSeverywhere: Douglas Crockford - JavaScript, The World's Most Misunderstood Language]'.


== Where do I find general information about JavaScript? ==
== Where do I find general information about JavaScript? ==
Line 7: Line 9:
=== Online resources: ===
=== Online resources: ===
* [http://en.wikipedia.org/wiki/JavaScript JavaScript (Wikipedia)]
* [http://en.wikipedia.org/wiki/JavaScript JavaScript (Wikipedia)]
* [http://www.w3schools.com/JS/ JavaScript Tutorial] at W3Schools.com
* [http://articles.sitepoint.com/category/javascript Sitepoint JavaScript tutorials]
* [http://articles.sitepoint.com/category/javascript Sitepoint JavaScript tutorials]


=== Books: ===
=== Books: ===
* [http://shop.oreilly.com/product/9780596517748.do JavaScript: The Good Parts] by Douglas Crockford
* [http://oreilly.com/catalog/9780596101992 JavaScript: The Definitive Guide, Fifth Edition] by David Flanagan - Really the ultimate reference guide (nearly 1000 pages).
* [http://oreilly.com/catalog/9780596101992 JavaScript: The Definitive Guide, Fifth Edition] by David Flanagan - Really the ultimate reference guide (nearly 1000 pages).
* [http://www.sitepoint.com/books/jsant1/ The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks] by James Edwards & Cameron Adams - Promotes accessible JavaScript solutions by following the principles of [[Progressive enhancement| progressive enhancement]] and [[Unobtrusive_Javascript| unobtrusive scripting]].
* [http://www.sitepoint.com/books/jsant1/ The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks] by James Edwards & Cameron Adams - Promotes accessible JavaScript solutions by following the principles of [[Progressive enhancement| progressive enhancement]] and [[Unobtrusive_Javascript| unobtrusive scripting]].
Line 16: Line 18:
== How is JavaScript used by Moodle? ==
== How is JavaScript used by Moodle? ==


* See [https://docs.moodle.org/en/Category:Javascript Category:Javascript].
* See [[Javascript]].


== Where do I find more information about JavaScript in Moodle? ==
== Where do I find more information about JavaScript in Moodle? ==
Line 24: Line 26:


== What JavaScript library does Moodle use? ==
== What JavaScript library does Moodle use? ==
 
=== JQuery ===
=== Yahoo! User Interface Library (YUI) ===  
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]].
Moodle uses the Yahoo! User Interface Library (YUI).
 
==== Online resources: ====
* [http://developer.yahoo.com/yui/ Yahoo! User Interface Library (YUI)]
* [[YUI]] in the Moodle documentation
 
==== Books: ====
* [http://www.packtpub.com/yahoo!-user-interface-library-yui/book Learning the Yahoo! User Interface Library] by Dan Wellman
 
==== How/Why was YUI chosen for Moodle? ====
 
The decision was made in [http://moodle.org/mod/forum/discuss.php?d=48478 this thread in the General Developer Forum].
 
==== yui_module function in Moodle 2.0 ====
See [http://moodle.org/mod/forum/discuss.php?d=154359 JavaScript Cache and YUI Modules] and MDL-22920.
 
== What other JavaScript libraries are around? ==
 
* A nice comparison chart: [http://wiki.freaks-unidos.net/javascript-libraries Evaluation of JavaScript Libraries]
 
=== jQuery ===
 
jQuery is another popular JavaScript library, used among others by Drupal, Joomla and WordPress.


==== Online resources: ====
==== Online resources: ====
* [http://addyosmani.com/writing-modular-js/ Writing Modular Javascript]
* [http://jqueryenlightenment.com/jquery_enlightenment.pdf JQuery Enlightenment]
* [[jQuery]] in Moodle
* [http://jquery.com/ jQuery]  
* [http://jquery.com/ jQuery]  
* [http://visualjquery.com Visual jQuery]
* [http://visualjquery.com Visual jQuery]
Line 60: Line 42:
* [http://www.packtpub.com/jquery-reference-guide-Open-Source/book jQuery Reference Guide] by Jonathan Chaffer and Karl Swedberg
* [http://www.packtpub.com/jquery-reference-guide-Open-Source/book jQuery Reference Guide] by Jonathan Chaffer and Karl Swedberg


==== Moodle Docs ====
=== Yahoo! User Interface Library (YUI) ===
* [[Using jQuery with Moodle 2.0]]
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: ====
* [http://yuilibrary.com Yahoo! User Interface Library (YUI)]
* [[YUI]] in the Moodle documentation
* [https://alloyui.com/rosetta-stone/ Migrating YUI code to jQuery]
 
==== Books: ====
* [http://shop.oreilly.com/product/0636920013303.do YUI 3 Cookbook] by Evan Goer
* [http://shop.oreilly.com/product/0636920025245.do 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


== What does AJAX mean? ==
== 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.
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 [http://en.wikipedia.org/wiki/Ajax_(programming) AJAX (Wikipedia)] for general information and [[AJAX]] for information on AJAX and Moodle.
See [http://en.wikipedia.org/wiki/Ajax_(programming) AJAX (Wikipedia)] for general information and [[AJAX]] for information on AJAX and Moodle.
Line 72: Line 72:
== See also ==
== See also ==


* [[User:Frank_Ralf/JavaScript1]] compares different solutions (plain JavaScript, YUI, and jQuery) to a simple enhancement to a form.
* [[jQuery]]
* [[Using jQuery with Moodle 2.0]]
* [[Javascript and YUI 3 FAQ]]
* [[Javascript and YUI 3 FAQ]]



Revision as of 14:18, 10 December 2018

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:

How is JavaScript used by Moodle?

Where do I find more information about JavaScript in Moodle?

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:

Books:

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:

Books:

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

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.

See also