Development:JavaScript usage guide: Difference between revisions
From MoodleDocs
m (Development:Javascript usage guide moved to Development:JavaScript usage guide: fixed capital S) |
|||
Line 18: | Line 18: | ||
Types of JS code in 1.9: | Types of JS code in 1.9: | ||
* JS scripts linked from page head | |||
* JS linked and executed from page head | |||
* inline Javascript | |||
* global JS variables | |||
Overview of JavaScript usage in 2.0 | |||
* majority of JS logic | * all JS stored in one global M namespace | ||
* | * majority of JS logic moved into page footer | ||
* | * loading of javascript modules handled by YUI3 loader | ||
* | * all plugins support module.js files | ||
* | * most JS is initialised through $PAGE->requires->js_init_call() | ||
* full migration to YUI3, YUI2 modules are loaded on demand only | |||
=Sample usage of JavaScript in module= | |||
=Description of M namespace= | |||
=Performance improvements= | |||
=Migration and code upgrade steps= | |||
==Deprecated coding style== | |||
=Examples= | =Examples= |
Revision as of 11:02, 27 January 2010
Note: This article is a work in progress. Please use the page comments or an appropriate moodle.org forum for any recommendations/suggestions for improvement.
Template:Infobox Project
Template:Moodle 2.0
Goals
- standardised usage of Javascript code in Moodle
- improved performance
- improve and simplify JS related APIs
API overview
Types of JS code in 1.9:
- JS scripts linked from page head
- JS linked and executed from page head
- inline Javascript
- global JS variables
Overview of JavaScript usage in 2.0
- all JS stored in one global M namespace
- majority of JS logic moved into page footer
- loading of javascript modules handled by YUI3 loader
- all plugins support module.js files
- most JS is initialised through $PAGE->requires->js_init_call()
- full migration to YUI3, YUI2 modules are loaded on demand only