Affects Version/s: 2.3.2
Fix Version/s: None
Pull from Repository:
Pull Master Branch:
Pull Master Diff URL:
We're now beginning to adds more and more YUI modules to moodle.
At present, each call to yui_module means that we add something like:
The way that the YUI loader works what then happens is:
- the Y.use() is processed by the browser
- the YUI (JS) loader then loads the JS for the specified modules (moodle-course-modchooser) and issues a call for the JS (/theme/yui_combo.php?moodle/-1/course/yui/modchooser/modchooser.js)
- the newly downloaded JS is parsed and its list of dependencies is read
- The list of dependencies is now downloaded (base, overlay, moodle-core-chooserdialogue, transition)
- The list of dependencies for moodle-core-chooserdialogue is now read and they are downloaded
As a result, for the modchooser we've now made:
- 1 call for modchooser.js
- 1 call for modchooser's dependencies
- 1 call for the dependencies of the dependencies
- possibly more calls for yet more dependencies.
That's at least three browser fetches.
The way that the core YUI side of things gets around this is to preseed its list of dependencies somehow. We should really look at putting some way of doing this in place to reduce the amount of unnecessary page calls.
Additionally, we should look at combining the list of YUI modules that we're using into a single Y.use(), for example:
This would mean that we combine all of the modules into one page load, those are all evaluated at once, and their dependences loaded once. This should reduce page load count.
I've put a quick proof-of-concept together.
On a course editing page, with the fix for
MDL-36099 included, the number of requests related to JS reduces from 23 to 18.
Adding in some of the module dependencies reduces this further to 15.
If the file drag/drop were rewritten as a YUI module this would reduce further to 14.