> For the complete documentation index, see [llms.txt](https://quantumphp.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://quantumphp.gitbook.io/docs/packages/asset/overview.md).

# Overview

Asset manages CSS and JavaScript tags for your views from one shared registry.

Use it when you want to register frontend files in controllers, services, or modules and render them later in a layout.

## What it provides

* `Asset` value objects for individual CSS or JavaScript entries
* `AssetManager` for registration, lookup, URL generation, and output
* `asset()` helper for the shared manager instance
* `assets('css')` and `assets('js')` helpers for rendering tags

## Quick example

```php
use Quantum\Asset\Asset;

asset()->register([
    new Asset(Asset::CSS, 'css/app.css', 'app'),
    new Asset(Asset::JS, 'js/app.js', 'app', 10, ['defer']),
]);
```

In your layout:

```php
<head>
    <?php assets('css'); ?>
</head>
<body>
    <?php assets('js'); ?>
</body>
```

## How paths work

Relative paths are published under `base_url() . '/assets/'`.

That means `css/app.css` becomes something like `/assets/css/app.css`.

Absolute URLs keep their original value, so CDN links can be registered directly.

## When to use positions

Use the optional position argument when load order matters.

Lower positions render first inside the same asset type. Assets without an explicit position are placed into the next free slot after positioned entries are reserved.

## Operational constraints

* Asset names must be unique when you provide them.
* CSS and JavaScript are rendered separately.
* The helper returns one shared manager instance for the current process, so registered assets stay in memory until you flush them.
* `assets()` only accepts the built-in type keys: `css` and `js`.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://quantumphp.gitbook.io/docs/packages/asset/overview.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
