Edit this page

up.script up.script.config
Configuration object

Configures defaults for script handling and asset tracking.


Assets

[config.assetSelectors]
optional

An array of CSS selectors matching default assets.

By default, all remote scripts and stylesheets in the <head> are considered assets. Inline scripts and internal styles are not tracked by default, but you can include them with an [up-asset] attribute.

Unpoly only tracks assets in the <head>. Elements in the <body> are never tracked, even if they match one of the configured selectors.

See Tracking assets for examples.

Array<string
[config.noAssetSelectors]
optional

Exceptions to up.script.config.assetSelectors.

Matching elements will not be considered assets, even if they match up.script.config.assetSelectors.

Array<string

Scripts

[config.scriptSelectors]
optional

An array of CSS selectors matching elements that run JavaScript.

By default, this matches all <script> elements with a JavaScript type.

This configuration does not affect what Unpoly considers assets. For this, configure up.script.config.assetSelectors.

Array<string
[config.noScriptSelectors]
optional

Exceptions to up.script.config.scriptSelectors.

Array<string
[config.evalCallbackPolicy='auto']
optional

Whether Unpoly will run callbacks in HTML attributes like ([up-on-loaded])(/up-follow#up-on-loaded).

string
[config.scriptElementPolicy='auto']
optional
string
[config.cspNonce]
optional

A CSP script nonce for the initial page that booted Unpoly.

The nonce lets Unpoly run JavaScript in HTML attributes like [up-on-loaded] or [up-on-accepted]. See Restricting callbacks with nonces.

The nonce can either be configured as a string or as a function that returns the nonce.

Defaults to the content attribute of a <meta> tag named csp-nonce:

<meta name='csp-nonce' content='secret4367243'>
stringFunction(): string
[config.cspWarnings=true]
optional

Whether Unpoly will print a warning when it observes a potentially unsafe Content-Security-Policy header.

boolean