Include third-party JS lib (like jQuery or others) in Moodle 3.9

Include third-party JS lib (like jQuery or others) in Moodle 3.9

by Stefano Pettorossi -
Number of replies: 2

Hi,

as per the subject, I would like to understand what is the current best-practice to include JS libraries in my activity module plug-in (I'm developing in Moodle 3.9.1).

Is this documentation page still current? -> https://docs.moodle.org/dev/Javascript_Modules

Or this? -> https://docs.moodle.org/dev/Guide_to_adding_third_party_jQuery_for_AMD

Or this one? -> https://docs.moodle.org/dev/NPM

I strive to adhere as precisely as possible to Moodle's standards and best-practices.

Thanks in advance to anyone who can help me out

Average of ratings: -
In reply to Stefano Pettorossi

Re: Include third-party JS lib (like jQuery or others) in Moodle 3.9

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Those 3 docs you link to are all current and legitimate, covering 3 distinct topics.

The first ( https://docs.moodle.org/dev/Javascript_Modules ) tells you how to write custom javascript for your plugin.

The second ( https://docs.moodle.org/dev/Guide_to_adding_third_party_jQuery_for_AMD ) is one method to make use of a 3rd-party javascript library in your custom javascript code (I've not read it in detail, so I cannot vouch for how up to date it is).

The third ( https://docs.moodle.org/dev/NPM ) is related to adding the development tools used to minify your javascript, compile SCSS files into CSS for themes, etc. - it is only for use on a development system and will never be used in production (other than the fact that the minified javascript / compiled CSS that was generated by those tools will be deployed into production).
Average of ratings: Useful (1)