javascript global M object

javascript global M object

by Murad Jamal -
Number of replies: 1

I opened the file lib/javascript-static.js and read through it, but noticed that there is a namespace (M) used all over the file and used with almost each JS function call in moodle2, my question is where this object is initialized ? there is note on top of the file that says:

Global M object is initilised in inline javascript

but couldn't find any example of this initialization ...

can anybody help me where to find such initialization ?

thanks in advance.

Average of ratings: -
In reply to Murad Jamal

Re: javascript global M object

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

There is a small amount of JavaScript written into the HTML header that includes creating M. It is done by the page_requirements_manager::get_head_code method in lib/outputrequirementslib.php.