Runtime environment

By default, Asciidoctor.js will try its best to automatically detect the runtime environment using Duck typing.

Configure the Runtime environment

The following section covers an advanced topic. For most use cases, you don’t need to explicitly configure the runtime environment.

Now that you have been warned, you can use the runtime configuration object when instantiating Asciidoctor.js to explicitly define the runtime environment:

const asciidoctor = require('asciidoctor')({
  runtime: {
    platform: 'browser',
    engine: 'v8',
    framework: 'webextensions'

The following values are recognized:

  • node: Node.js

  • java: Java (GraalVM)

  • standalone: Standalone (spidermonkey)

  • browser: Browser (Chrome, Firefox, Opera, Edge…​)


I/O module

The I/O module provides an implementation for reading files.

By default, Asciidoctor.js will determine the I/O module upon the runtime environment. To explicitly define the I/O module, you can specify the attribute runtime.ioModule when instantiating Asciidoctor.js:

const asciidoctor = require('asciidoctor')({
  runtime: {
    ioModule: 'xmlhttprequest'

ioModule can be one of:


The implementation will use the fs module.


The implementation will use the XMLHttpRequest object.


The implementation will use a bounded class named IncludeResolver:

context.getPolyglotBindings().putMember("IncludeResolver", new IncludeResolver());

The implementation will use the read function.


The implementation will use the function.

Retrieve the runtime environment

Once Asciidoctor.js is instantiated, you can retrieve the runtime environment with the getRuntime function:

const asciidoctor = require('asciidoctor')()
// { ioModule: 'node', platform: 'node', engine: 'v8', framework: '' }

It can be useful to make sure that the runtime environment has been correctly determined.