Details
-
Sub-task
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
2.5
-
MOODLE_25_STABLE
-
MOODLE_25_STABLE
-
Description
As raised in discussion on the General Developer Forum at https://moodle.org/mod/forum/discuss.php?d=217450, shifter has some great benefits that I feel we should explore.
In summary these benefits include:
- minification of JS;
- metadata creation which we can use for dependency management to inform loader configuration and reduce page waterfalls;
- linting of JS code using the same tools as the YUI team use themselves;
- the ability to run JS tests and code coverage; and
- the ability to leave various logging in place within debug versions of code to aid debugging.
Of course, all of this is not free and it does require that developers install the shifter tool on their machines. This itself requires [node.js](http://nodejs.org), though nodejs can be installed using [composer](https://packagist.org/packages/nervo/node).
Also, unfortunately the change prevents direct use of the source JS files without them going through some form of build process. This can be achieved easily with shifter which has a --watch function to build files as they change. Additionally, it is possible to perform the basic build process within the YUI loader to allow users to make some basic changes if they wish (but only in jsrev = -1 mode).
Such a change would not be mandated for non-core modules, but I believe that we should try and get all core modules to move to the new system ASAP. The major benefit here is Linting which would likely improve our computability with some older browsers. Through changes to the YUI combo loader, it's possible to support both methods with the new YUI module method being used in preference.
We would of course need to update our documentation to support developers, though this is something that we really need to do for JS anyway.