---
title: "Asset ViewHelper <vite:asset>"
manual: "Vite AssetCollector"
version: "2.0"
permalink: "https://docs.typo3.org/permalink/praetorius/vite-asset-collector:viewhelper-asset@2.0"
source: "Reference/ViewHelpers/Asset.rst"
rendered: "2026-11-18T12:35:45+00:00"
---

# Asset ViewHelper `<vite:asset>` {#viewhelper-asset}

The `<vite:asset>` ViewHelper embeds all JavaScript and CSS belonging to the
specified vite `entry` using TYPO3's AssetCollector API. It automatically
switches between Vite's development server and production rendering
(manifest.json) based on the extension's configuration.

Assets are embedded with the following defaults:

-   Scripts are embedded as JavaScript modules using `<script type="module">`
    at the end of the document
-   CSS files use `<link rel="stylesheet">` in the `<head>`
-   Imported JavaScript modules are preloaded automatically using
    `<link rel="modulepreload">`
-   Referenced fonts in the woff2 format are preloaded automatically using
    `<link rel="preload">`

These defaults can be configured by nesting
[\<vite:asset.script>](https://docs.typo3.org/permalink/praetorius/vite-asset-collector:viewhelper-asset-script@2.0),
[\<vite:asset.css>](https://docs.typo3.org/permalink/praetorius/vite-asset-collector:viewhelper-asset-css@2.0),
[\<vite:asset.font>](https://docs.typo3.org/permalink/praetorius/vite-asset-collector:viewhelper-asset-font@2.0)
and/or
[\<vite:asset.image>](https://docs.typo3.org/permalink/praetorius/vite-asset-collector:viewhelper-asset-image@2.0)
inside `<vite:asset>` (see examples below). Each of them can be used once.

## Example: Basic usage {#example-basic-usage}

```html
<vite:asset entry="EXT:sitepackage/Resources/Private/JavaScript/Main.entry.js" />
```

## Example: Inlining CSS {#example-inlining-css}

```html
<vite:asset entry="EXT:sitepackage/Resources/Private/JavaScript/Main.entry.js">
    <vite:asset.css inline="{true}" />
</vite:asset>
```

## Example: Disable automatic preloading {#example-disable-automatic-preloading}

```html
<vite:asset entry="EXT:sitepackage/Resources/Private/JavaScript/Main.entry.js">
    <vite:asset.script preloadImports="{false}" />
    <vite:asset.font preload="{false}" />
</vite:asset>
```

## Example: Media query for CSS {#example-media-query-for-css}

```html
<vite:asset entry="EXT:sitepackage/Resources/Private/Css/Print.entry.css">
    <vite:asset.css media="print" />
</vite:asset>
```

**Arguments**

The following arguments are available for the asset ViewHelper:

-   **addCss**

    -   *Type:* boolean
    -   *Default:* true

    Deprecated, use \<vite:asset.css> instead. (If set to "false", CSS files associated with the entry point won't be added to the asset collector)

-   **csp**

    -   *Type:* bool

    Whether to collect a CSP hash value for this asset (default: true for external files, false for inline)

-   **cssTagAttributes**

    -   *Type:* array
    -   *Default:* array (
    )

    Deprecated, use \<vite:asset.css> instead. (Additional HTML attributes for css link tags.)

-   **entry**

    -   *Type:* string

    Identifier of the desired vite entrypoint; this is the value specified as "input" in the vite configuration file. Can be omitted if manifest file exists and only one entrypoint is present.

-   **inlineCss**

    -   *Type:* boolean
    -   *Default:* false

    Deprecated, use \<vite:asset.css> instead. (If set to "true", CSS will be added as inline \<style> tag.)

-   **manifest**

    -   *Type:* string

    Path to your manifest.json file. If omitted, default manifest from extension configuration will be used instead.

-   **priority**

    -   *Type:* boolean
    -   *Default:* false

    Deprecated, use \<vite:asset.css> for CSS and \<vite:asset.script> for scripts instead. (Include assets before other assets in HTML)

-   **scriptTagAttributes**

    -   *Type:* array
    -   *Default:* array (
    )

    Deprecated, use \<vite:asset.script> instead. (Additional HTML attributes for script tags)

-   **useNonce**

    -   *Type:* bool

    Deprecated, use csp instead. (Whether to use the global nonce value)
