MDL-68677 core: Enable prefetching when cachejs is disabled
authorAndrew Nicols <andrew@nicols.co.uk>
Tue, 12 May 2020 01:21:03 +0000 (09:21 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 14 May 2020 06:10:55 +0000 (14:10 +0800)
With the templaterev issue resolved we should enable the prefetch module
when cachejs is enabled to avoid a different experience when cachejs is
enabled vs. disabled.

Previously there was little point in doing this due to a range of other
bugs (string normalisation, and misuse of templaterev).

With these issues resolved we should enabel the caching.

lib/amd/build/prefetch.min.js
lib/amd/build/prefetch.min.js.map
lib/amd/src/prefetch.js
lib/outputrequirementslib.php

index 94652dc..95f70ab 100644 (file)
Binary files a/lib/amd/build/prefetch.min.js and b/lib/amd/build/prefetch.min.js differ
index ea27ce4..060c3c0 100644 (file)
Binary files a/lib/amd/build/prefetch.min.js.map and b/lib/amd/build/prefetch.min.js.map differ
index e8e6fb8..b69606f 100644 (file)
@@ -75,11 +75,6 @@ const fetchQueue = () => {
  * Subsequent fetches are immediate.
  */
 const processQueue = () => {
-    if (Config.jsrev <= 0) {
-        // No point pre-fetching when cachejs is disabled as we do not store anything in the cache anyway.
-        return;
-    }
-
     if (prefetchTimer) {
         // There is a live prefetch timer. The initial prefetch has been scheduled but is not complete.
         return;
index 236b0ed..7bca2a7 100644 (file)
@@ -1390,9 +1390,7 @@ class page_requirements_manager {
         // First include must be to a module with no dependencies, this prevents multiple requests.
         $prefix = 'M.util.js_pending("core/first");';
         $prefix .= "require(['core/first'], function() {\n";
-        if ($cachejs) {
-            $prefix .= "require(['core/prefetch']);\n";
-        }
+        $prefix .= "require(['core/prefetch']);\n";
         $suffix = 'M.util.js_complete("core/first");';
         $suffix .= "\n});";
         $output .= html_writer::script($prefix . implode(";\n", $this->amdjscode) . $suffix);