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

Stop bundling all files in first.js

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.8
    • Fix Version/s: None
    • Component/s: JavaScript
    • Labels:
      None
    • Affected Branches:
      MOODLE_38_STABLE

      Description

      I've done a bit of research, and I believe that bundling all compiled JS in first.js is a false economy with significant drawbacks.

      At the moment, the first time a page is loaded we load all AMD JS in Moodle.

      This currently accounts for approximately 900KB and growing.

      The TTFB is also high at about 80ms as we combine all of the various files and then echo them out at the end. This therefore also has an impact on memory as all of this content is stored in memory until it is echoed out (peak memory usage just before we finish compiling is about 1.3MB).

      If any single JS file has an issue then all JS on the site will fail.

      Additionally when we debug we change things around and send the unminified sources instead (about 9.5MB).

      All of this means negative things for scale, for user experience, reliability, for browser memory usage, and for debugging.

      I believe that, once MDL-62497 lands, we will be able to switch to one AMD module per request and leverage browser caching far more effectively.
      With the introduction of source maps in 62497, we can make these always available for files which have one, to facilitate easier debugging of production systems.

      From what I can see, whilst the first load will require more files to be fetched, these will be fetched faster, and cached more efficiently. We will also be more reliable, and less browser memory.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                dobedobedoh Andrew Nicols
                Participants:
                Component watchers:
                Jake Dallimore, Jun Pataleta
              • Votes:
                1 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: