This documentation describes unreleased changes on the main branch.

loadScript()

Function of @saij/wp-app-framework/view.

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

Loads an external script, 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; true for an attribute without value.

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