diff --git a/lib/outputrequirementslib.php b/lib/outputrequirementslib.php index 9cf473503e6..c7c0aa14070 100644 --- a/lib/outputrequirementslib.php +++ b/lib/outputrequirementslib.php @@ -1326,6 +1326,9 @@ class page_requirements_manager { protected function get_amd_footercode() { global $CFG; $output = ''; + + // We will cache JS if cachejs is not set, or it is true. + $cachejs = !isset($CFG->cachejs) || $CFG->cachejs; $jsrev = $this->get_jsrev(); $jsloader = new moodle_url('/lib/javascript.php'); @@ -1341,15 +1344,21 @@ class page_requirements_manager { $jsextension = ''; } + $minextension = '.min'; + if (!$cachejs) { + $minextension = ''; + } + $requirejsconfig = str_replace('[BASEURL]', $requirejsloader, $requirejsconfig); $requirejsconfig = str_replace('[JSURL]', $jsloader, $requirejsconfig); + $requirejsconfig = str_replace('[JSMIN]', $minextension, $requirejsconfig); $requirejsconfig = str_replace('[JSEXT]', $jsextension, $requirejsconfig); $output .= html_writer::script($requirejsconfig); - if ($CFG->debugdeveloper) { - $output .= html_writer::script('', $this->js_fix_url('/lib/requirejs/require.js')); - } else { + if ($cachejs) { $output .= html_writer::script('', $this->js_fix_url('/lib/requirejs/require.min.js')); + } else { + $output .= html_writer::script('', $this->js_fix_url('/lib/requirejs/require.js')); } // First include must be to a module with no dependencies, this prevents multiple requests. diff --git a/lib/requirejs/moodle-config.js b/lib/requirejs/moodle-config.js index acce48ee5c3..32602508e49 100644 --- a/lib/requirejs/moodle-config.js +++ b/lib/requirejs/moodle-config.js @@ -6,8 +6,8 @@ var require = { waitSeconds : 0, paths: { - jquery: '[JSURL]lib/jquery/jquery-3.2.1.min[JSEXT]', - jqueryui: '[JSURL]lib/jquery/ui-1.12.1/jquery-ui.min[JSEXT]', + jquery: '[JSURL]lib/jquery/jquery-3.2.1[JSMIN][JSEXT]', + jqueryui: '[JSURL]lib/jquery/ui-1.12.1/jquery-ui[JSMIN][JSEXT]', jqueryprivate: '[JSURL]lib/requirejs/jquery-private[JSEXT]' },