General developer forum

Javascript code changes not reflecting

Picture of Mahtab Hussain
Javascript code changes not reflecting

May you live in peace!

I am updating a plugin developed for Moodle 2.6 to Moodle 3.4. The plugin uses Javascript files for different functions.

I am getting following errors:

  1. $ is not defined
  2. jQuery is not defined

To correct above issues, I enclosed the code in Javascript files within: 

require(['jquery'], function($) { 

         // JQuery is available via $ 


But, when I reload the pages, changes in Javascript do not reflect in developer tools. I have already 

  • Put site into developer mode
  • Turned theme designer mode
  • Turned off Javascript cache and YUI blocks configuration

Not sure what I am doing wrong. Hope the gurus here will assist.

Warm regards,

Mahtab Hussain

Average of ratings: -
Picture of Justin Hunt
Re: Javascript code changes not reflecting
Particularly helpful MoodlersPlugin developers

You will either need to rewrite the javascript as AMD modules,

or use the old means of accessing jquery

AMD modules are really the way to go. But there is a bit of a learning curve.

Average of ratings: -