Skip to main content
  • Guides & Documentation

Knowledgebase

Featured articles, how-to guides and quick tips.

YUI not defined JavaScript Error In Moodle 3

Moodle 3 is heavily reliant on JavaScript, and utilizes the YUI libraries to power quite a lot of front-end functionality in core. Themes and plugins can also make use of the YUI libraries, which makes it a fairly integral part of your Moodle front-end.

One common, but unfortunate, error that is often uncovered via the JavaScript console is the dreaded "YUI not defined" error.

When this error is present on your Moodle site you'll likely experience a plethora of issues regarding the frontend functionality of your site. In short, it's fairly essential that this problem is rectified.

If the YUI libraries have been functioning well on your site previously, and particularly if the error arose only after a recent server or site migration, it's highly possible that this is due to a conflict between Moodle's implementation of the YUI libraries and your server configuration.

The most common culprit of this error is the zlib.output_compression value on your server.

For sites who run PHP as an Apache module, you should aim to enable zlib.output_compression for your site.

However, for sites that run PHP-FPM, and particularly if you're running Nginx coupled with Varnish to power reverse-proxy delivery of your content, you'll want to ensure that zlib.output_compression is switched off for your Moodle site. This is particularly the case if you're running into issues of double-compression. You always want to avoid attempting to double-compress files, which can be somewhat of an issue when running a reverse proxy on your server.

If you're using PHP as an Apache module, you'll want to make this modification either in your php.ini file, or in your local .htaccess file (which should be located in your Moodle root directory), and if you're using PHP-FPM the following line should appear in your .user.ini file, local to your Moodle root:

zlib.output_compression = Off

Following your changes to your ini file, you should purge all Moodle caches and refresh your browser cache and cookies, as well as purging any CDN caches associated with Moodle. This will ensure that you are delivered the most up-to-date versions of the compiled YUI files.