Skip to main content

Constructor

The constructor resolves config.element immediately and begins initialisation asynchronously.

element: string | HTMLElement

Either an id (as a string without the #) or an HTMLElement reference. If the id does not resolve, the constructor throws Element not found: <id>.

src: string

URL of a ScreenJSON document. Fetched and parsed by the internal DocumentLoader.

document: ScreenJSONDocument

Pre-loaded ScreenJSON document. Takes precedence over src when both are provided.

Loading precedence

When no document is passed, the loader looks for a source in this order:
  1. config.src
  2. The ?src= query parameter on the current page URL
  3. The data-src / data-source attribute on the currently executing <script> tag (CDN embed)
If none resolve, the viewer renders an error with a “No Document Source” suggestion.

Callbacks

Complete example

See Options for the full config table.