loadScript()

Function of @saij/wp-app-framework.

import { loadScript } from '@saij/wp-app-framework';
function loadScript(url: string, attributes?: Record<string, string | boolean>): Promise<void>

Loads an external script, such as the library of a map service, once per URL and document.

ParameterTypeDescription
urlstringAn https: URL or a protocol-relative one (//…).
attributes?Record<string, string | boolean>Further attributes of the script element, such as integrity or crossorigin; true for an attribute without value.

Returns Promise<void>: Fulfilled once the script has loaded; rejected if it fails to load.