Asset.script ViewHelper <vite:asset.script> 

The <vite:asset.script> ViewHelper allows to customize the embedding of script assets with the <vite:asset> ViewHelper. It can only be used as a direct child element of <vite:asset>.

See <vite:asset> for more examples.

Example: Disable preloading of imports 

<vite:asset entry="EXT:sitepackage/Resources/Private/JavaScript/Main.entry.js">
    <vite:asset.script preloadImports="{false}" />
</vite:asset>
Copied!

Arguments

The following arguments are available for the asset.script ViewHelper:

additionalAttributes

additionalAttributes
Type
array
Default
array ( )
Additional attributes to be added to the <script> tag.

async

async
Type
bool
Default
false
Set to "true" if the script should be executed as soon as it is loaded. Can be used for JavaScript modules and classic scripts.

defer

defer
Type
bool
Default
false
Set to "true" if the classic script should be executed after the document has been parsed. JavaScript modules are always deferred, so this can only be used with module="{false}".

ignore

ignore
Type
bool
Default
false
Set to "true" if the script should not be embedded at all.

module

module
Type
bool
Default
true
Set to "false" if the script should be embedded as a classic script instead of a JavaScript module (e. g. for non-ESM build output).

nomodule

nomodule
Type
bool
Default
false
Set to "true" if the classic script should be used as an alternative to a JavaScript module. Can only be used with module="{false}".

preloadImports

preloadImports
Type
bool
Default
true
Set to "false" if imported scripts should not be preloaded automatically.

priority

priority
Type
bool
Default
false
Set to "true" if the script should be embedded in the <head> of the document.