Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-78465

Lib: Moodle sometimes loads entire AMD javascript twice

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Minor Minor
    • None
    • 4.0.9
    • JavaScript
    • None
    • MOODLE_400_STABLE

      When a Moodle course (or other) page loads, it may load the entire AMD javascript twice, by requests to these two files:

      /lib/requirejs.php/1686659947/core/first.js
      /lib/requirejs.php/1686659947/core_form/events.js

      The content of both files is identical (in current master on my server 2.67MB, 544.54KB transferred).

      I find this happens the OU live system sometimes, but not on every request (this may be because of the sheer size of the JS when OU plugins are added too makes it take longer to load even when cached). However, I can reproduce on my developer server using current master as follows:

      1 Using browser developer tools, turn on the 'Disable caches' option.
      2 On the network panel, set the filter to 'requirejs' (and clear any existing data)
      3 Reload the course page

      This should result in two files require.min.js and first.js. But in fact, there is also an events.js file.

      This occurs because the Y.use lines in the footer do not wait until after core/first is loaded, and code in lib/yui/src/event/js/event.js does an AMD require for core_form/events.

            Unassigned Unassigned
            quen Sam Marshall
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.