Type: New Feature
Affects Version/s: 3.8
Fix Version/s: None
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.