scriptTag
The markup of one script: <script src nonce> (with async for afterInteractive), or nothing for lazyOnload, which the browser loads itself.
The markup of one script: <script src nonce> (with async for afterInteractive), or nothing for
lazyOnload, which the browser loads itself. Attribute values are escaped.
Import#
ts
import { scriptTag } from "@shadow-js/dusk";
Signature#
ts
function scriptTag(options: ScriptOptions): string
Parameters#
| Name | Description |
|---|---|
options |
The source, strategy and nonce. |
Returns#
The markup (empty for lazyOnload).
Throws#
- TypeError for a source that is not a path or an http(s) URL, or a nonce that is not a token.
Examples#
ts
scriptTag({ src: "/polyfill.js", strategy: "beforeInteractive", nonce: event.nonce });