Using Dusa in your JavaScript programs
As Julia Evans describes, in 2024 there are basically three ways use JavaScript code in your project.
- A “classic” module that just defines a global variable
- An ES module
- Use a build system
Classic modules
To use Dusa in your random web page, include the UMD module in a script tag in the head of your file, for example with unpkg like this:
or with jsdelivr like this:
This defines the Dusa
name, which can be used to make new Dusa classes or
access the various helpers.
ES modules
ES modules can be used to access the Dusa
class and the
helpers in any development using ES modules, without
requiring any build system.
The val.town examples used elsewhere in the docs use this way of importing Dusa. Here’s the example above on val.town.
Build system imports
If import dusa
through NPM (or a similar package manager/build system), then
you can import the core Dusa
class as well as the
helpers through the 'dusa'
import.