This example demonstrates how to use itk.js in a web browser application via its pre-built UMD module. This is an alternative to bundling the modules with the Webpack application, as shown in the Webpack example. In this example, we re-use the itk.js IO modules published on unpkg.com. Find the full example in the
itk-js/examples/UMD directory of the GitHub repository.
Inside the HTML
head, load the itk.js UMD script:
itk object provides itk.js API functions and objects as properties.
Optionally, add an npm script that will start a local web server for development.
npm install --save-dev local-web-server
Next, define a
start command to start a local development web server in the scripts section of the
To start the development web server hosting the
dist/ directory contents, run
npm run start
This section described how to configure browser-based testing with the Karma test runner.
First, install Karma and a test harness library like tape.
npm install --save-dev karma karma-chrome-launcher karma-tap karma-tap-pretty-reporter karma-webpack tape tap-spec
Create entries in the
package.json file to start Karma, and run the tests!
npm run test