Skip to content

Function: loadScript()

Call Signature

ts
function loadScript(url, callbackfn?): void;

Loads a script dynamically.

Parameters

ParameterTypeDescription
urlstringThe URL of the script to load.
callbackfn?LoadScriptCallbackOptional callbackfn function to be called when the script is loaded or encounters an error.

Returns

void

Example

ts
console.log(typeof loadScript)
console.log(new Promise((resolve) => loadScript('https://example.com/x.js', resolve)) instanceof Promise)

Since

1.0.0

Call Signature

ts
function loadScript(options, callbackfn?): void;

Loads a script dynamically.

Parameters

ParameterTypeDescription
optionsLoadScriptOptions-
callbackfn?LoadScriptCallbackOptional callbackfn function to be called when the script is loaded or encounters an error.

Returns

void

Example

ts
console.log(typeof loadScript)
console.log(new Promise((resolve) => loadScript('https://example.com/x.js', resolve)) instanceof Promise)

Since

1.0.0

Released under the MIT License.