Permalink
Browse files

MDL-38507 JavaScript: Move definition of YUI_config before setup of S…

…impleYUI

Since moving to SimpleYUI, the order of inclusion for the YUI_config
variable is more important.

Simple YUI defines a global instance of YUI so that it can be used without
specifying the full YUI().use() syntax. As a result, any configuration
applied when that global instance is setup must exist already.
  • Loading branch information...
1 parent b3c7840 commit 43bd811891fe19aa43fd0bb9bf1ad9d3b392b1b4 @andrewnicols andrewnicols committed Mar 16, 2013
Showing with 8 additions and 5 deletions.
  1. +8 −5 lib/outputrequirementslib.php
@@ -1049,11 +1049,7 @@ public function get_head_code(moodle_page $page, core_renderer $renderer) {
// create circular references in memory which prevents garbage collection.
$this->init_requirements_data($page, $renderer);
- // YUI3 JS and CSS is always loaded first - it is cached in browser.
- $output = $this->get_yui3lib_headcode($page);
-
- // Now theme CSS + custom CSS in this specific order.
- $output .= $this->get_css_code();
+ $output = '';
// Set up global YUI3 loader object - this should contain all code needed by plugins.
// Note: in JavaScript just use "YUI().use('overlay', function(Y) { .... });",
@@ -1067,6 +1063,13 @@ public function get_head_code(moodle_page $page, core_renderer $renderer) {
$js = $this->YUI_config->update_header_js($js);
$output .= html_writer::script($js);
+ // YUI3 JS and CSS need to be loaded in the header but after the YUI_config has been created.
+ // They should be cached well by the browser.
+ $output .= $this->get_yui3lib_headcode($page);
+
+ // Now theme CSS + custom CSS in this specific order.
+ $output .= $this->get_css_code();
+
// Link our main JS file, all core stuff should be there.
$output .= html_writer::script('', $this->js_fix_url('/lib/javascript-static.js'));

0 comments on commit 43bd811

Please sign in to comment.