Modules

Overview

A module is a library of Javascript code that is published on the network somewhere that you can load and use in your Javascript code. That is, it is a page of code that defines a bunch of functions (and possibly other variables) that are available for use, after you load the code. The following shows how to load a module at the URL "http://server/utilities.js".


	let utils = await import('http://server/utilities.mjs');
	


Notice in this code, you assign a name to the imported module. The name can be any name you wish.

Once a module has been loaded, you have access to the functions defined therein. The following code demonstrates how you would call a function called test on the imported module.


	let utils = await import('http://server/utilities.mjs');
	
	let answer = utils.test();