Moodle

Clean up JavaScript usage in HEAD

Details

  • Type: Improvement Improvement
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 2.0
  • Fix Version/s: DEV backlog
  • Component/s: Libraries
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE

Description

See the sub tasks for details.

Issue Links

Progress
Resolved Sub-Tasks Unresolved Sub-Tasks

Sub-Tasks

Activity

Hide
Eloy Lafuente (stronk7) added a comment - - edited

I remember the IMS CP resource type also uses some "trick" to inject the needed js in the header.

Just to open the discussion to a related thing... I think it would be great to have some standard way to add onLoad and onUnload event listeners within Moodle, instead of having custom onLoad and onUnload js code here and there.

Edited: just for referece there are some nive addlisteners funcions (js) in : http://cvs.moodle.org/contrib/plugins/course/format/topicstree/loadunload.js?revision=1.1

Ciao

Show
Eloy Lafuente (stronk7) added a comment - - edited I remember the IMS CP resource type also uses some "trick" to inject the needed js in the header. Just to open the discussion to a related thing... I think it would be great to have some standard way to add onLoad and onUnload event listeners within Moodle, instead of having custom onLoad and onUnload js code here and there. Edited: just for referece there are some nive addlisteners funcions (js) in : http://cvs.moodle.org/contrib/plugins/course/format/topicstree/loadunload.js?revision=1.1 Ciao
Hide
Tim Hunt added a comment -

There are even nicer addListener funcitons in YUI, which is our recommended JS library!

Show
Tim Hunt added a comment - There are even nicer addListener funcitons in YUI, which is our recommended JS library!
Hide
Eloy Lafuente (stronk7) added a comment -

Great! Does YUI load always?

Show
Eloy Lafuente (stronk7) added a comment - Great! Does YUI load always?
Hide
Tim Hunt added a comment -

No, you need to do something like

require_js(array('yui_yahoo','yui_event'));

to load just he libraries you need - and that is what IMS CP should be doing, instead of horrible hacks. Admittedly, IMS CP and other things have been around longer than require_js has.

Show
Tim Hunt added a comment - No, you need to do something like require_js(array('yui_yahoo','yui_event')); to load just he libraries you need - and that is what IMS CP should be doing, instead of horrible hacks. Admittedly, IMS CP and other things have been around longer than require_js has.
Hide
Eloy Lafuente (stronk7) added a comment -

Yup, but it's nice to know there are newer ways to do that properly. Thanks!

Just for reference:

Show
Eloy Lafuente (stronk7) added a comment - Yup, but it's nice to know there are newer ways to do that properly. Thanks! Just for reference:
Hide
Tim Hunt added a comment -

Editing this bug to reflect the scope of the work that needs to be done. The original task of changing to use require_js everywhere is now a subtask.

Show
Tim Hunt added a comment - Editing this bug to reflect the scope of the work that needs to be done. The original task of changing to use require_js everywhere is now a subtask.

People

Vote (2)
Watch (7)

Dates

  • Created:
    Updated: