-
assigned issue to
- marked as enhancement
jQuery loading twice
The use of non-AMD jquery plugins causes jQuery itself to be loaded twice, once by Moodle core AMD-style (lib/requirejs/moodle-config.js via lib/requirejs.php), and once as a dependency of any $page->requires->jquery_plugin call in lib.php (via lib/outputrequirements.php).
Looking at the jquery plugins used, pace is AMD-aware and could be pulled in using js_call_amd('theme_adaptable/pace', 'start') with pace dumped in amd/src.
FlexSlider on github has an open pull request for AMD support (https://github.com/woothemes/FlexSlider/pull/1239), and I expect ticker and easing could trivially be modified in the same manner.
Upshot is that any requires->jquery_plugin should be within an "if" to detect Moodle versions that don't use AMD jquery, and requires->js_call_amd in the else...
Haven't looked into it to see why it doesn't seem to actually break anything.
Comments (3)
-
-
reporter Yep. Having looked over it yesterday, I don't think it would be all that big an effort; I might have a go at it if I run out of more urgent things to do (fat chance!)...
-
Probably the best, and easy, approach would be to remove one of the instances to improve the performance.
That should be easy and then we can improve the JS load later.
- Log in to comment
Adaptable is inherited from BCU that never used AMD.
Add AMD to Adaptable has a significant effort and since it is working, and therefore is not a bug, will be added in future releases.