util.addScript()

Add a script reference to the response head.

Syntax

util.addScript(scriptRelPath string) util.addScript(script File) util.addScript(response File, scriptRelPath string) util.addScript(response File, script File)

Parameters

scriptRelPath string

Reference the script file by a path relative to the current source file.

script File

Pass the script file as a File object.

response File

By default, the response file associated with the execution environment is used. You can override it and pass in a file yourself, which is useful when testing.

Description

Add a script reference to the response head.

The URL injected handles browser-side caching. When the referenced script file’s content changes, the returned URL will change accordingly.

Examples

Reference by path.

Reference by file.

Pass in custom response file.