Local JS AMD plugin only works with disabled cache

Local JS AMD plugin only works with disabled cache

Stephan L -
回帖数:6

Hi!

I try to setup a local plugin which hooks into H5P content by using their embed.php. Everything works as intended, when 'JavaScript Cache' is turned of (either through the config.php or admin dashboard). The plugin gets loaded, right after the video is initialized on the page.

But when caching is turned on, the plugin and some other JS files are not loaded at all (according to the browsers developer tools). I've observed this behaviour in Moodle 3.8.3 and now 3.9. Running grunt didn't solve the problem.

回复Stephan L

Re: Local JS AMD plugin only works with disabled cache

Justin Hunt -
Particularly helpful Moodlers的头像 Plugin developers的头像
There were changes in Moodle 3.8 to the way Moodle compiles and serves js. Some 3rd party plugins that defined AMD modules a particular way that had worked up until 3.8 broke. The problem is avoided when not caching because first.js ( a big fat aggregation of all plugins js) is not involved. Its the aggregating of those poorly defined JS modules that causes the issue.

This tracker issue covers it:
https://tracker.moodle.org/browse/MDL-67327
回复Stephan L

Re: Local JS AMD plugin only works with disabled cache

Dr. Nellie Deutsch -
I'm on Moodle 3.10. The menus freeze when I turn javascript cache to yes and Google Meet for Moodle stops working.
回复Dr. Nellie Deutsch

Re: Local JS AMD plugin only works with disabled cache

Dr. Nellie Deutsch -
I need cache Javascript on for Google Meet for Moodle plugin, otherwise everything is fine with it off.
回复Dr. Nellie Deutsch

Re: Local JS AMD plugin only works with disabled cache

Justin Hunt -
Particularly helpful Moodlers的头像 Plugin developers的头像
Nellie, it might be the Google Meet plugin, but not necessarily. However one of your plugins probably has poorly defined AMD modules. Its hard to say which ones. You might start by updating them all to the latest versions.
回复Justin Hunt

Re: Local JS AMD plugin only works with disabled cache

Dr. Nellie Deutsch -
Hi Justin, Thank you for responding. I have checked with the developer of Google Meet for Moodle about removing the need to cache Javascript. He claims it's part of the plugin and sees no way of removing it. I have upgraded all the plugins. How can I find poorly defined AMD modules?
回复Dr. Nellie Deutsch

Re: Local JS AMD plugin only works with disabled cache

Justin Hunt -
Particularly helpful Moodlers的头像 Plugin developers的头像
Nellie
Caching JS is not something the plugin can turn on or off. The plugin just needs to not break when its cached. It's quite hard to know what plugin is breaking the JS. There might be errors in the browser console that lead to it. We also do not know your Moodle version. You might need to get help for this.