# BootstrapPluginAsset

> Delivers the Bootstrap 6 JavaScript bundle as an ES module, with Floating UI and Vanilla Calendar Pro inlined.

[API reference](/docs/api/index.md) › [Bootstrap 6](/docs/extensions/bootstrap6/reference/index.md) › [asset](/docs/extensions/bootstrap6/reference/asset/index.md) › BootstrapPluginAsset

| final class | `yii2\extensions\bootstrap6\asset\BootstrapPluginAsset` |
| --- | --- |
| Extends | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) » [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) » [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| Implements | [`yii\base\Configurable`](/docs/api/yii/base/configurable/index.md) |
| Source | [`src/asset/BootstrapPluginAsset.php`](https://github.com/yii2-extensions/bootstrap6/blob/main/src/asset/BootstrapPluginAsset.php#L23) |

Delivers the Bootstrap 6 JavaScript bundle as an ES module, with Floating UI and Vanilla Calendar Pro inlined.

The bundle exposes no global; scripts access the plugins through `import()` of [`moduleUrl()`](/docs/extensions/bootstrap6/reference/asset/bootstrappluginasset/index.md#method-moduleUrl), or through
`window.bootstrap` when [`$exposeGlobal`](/docs/extensions/bootstrap6/reference/asset/bootstrappluginasset/index.md#property-exposeGlobal) is enabled.

See also: <https://getbootstrap.com/docs/6.0/getting-started/javascript/>.

## Properties

| Property | Type | Description | Defined by |
| --- | --- | --- | --- |
| <span id="property-basePath"></span>[`$basePath`](/docs/api/yii/web/assetbundle/index.md#property-basePath) | `string\|null` | The Web-accessible directory that contains the asset files in this bundle. Default: `null`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-baseUrl"></span>[`$baseUrl`](/docs/api/yii/web/assetbundle/index.md#property-baseUrl) | `string\|null` | The base URL for the relative asset files listed in [`$js`](/docs/api/yii/web/assetbundle/index.md#property-js) and [`$css`](/docs/api/yii/web/assetbundle/index.md#property-css). Default: `null`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-cdn"></span>[`$cdn`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#property-cdn) | `bool` | Whether to link the files from the CDN instead of publishing the local package. Default: `false`. | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) |
| <span id="property-cdnUrl"></span>[`$cdnUrl`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#property-cdnUrl) | `string` | Base URL of the CDN serving npm packages as `{cdnUrl}/{package}@{version}/{directory}/{file}`. Default: `'https://cdn.jsdelivr.net/npm'`. | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) |
| <span id="property-css"></span>[`$css`](/docs/api/yii/web/assetbundle/index.md#property-css) | `array<string\|array<array-key, mixed>>` | List of CSS files that this bundle contains. Default: `[]`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-cssOptions"></span>[`$cssOptions`](/docs/api/yii/web/assetbundle/index.md#property-cssOptions) | `yii\web\RegisterCssFileOptions` | The options that will be passed to [`View::registerCssFile()`](/docs/api/yii/web/view/index.md#method-registerCssFile) when registering the CSS files in this bundle. Default: `[]`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-depends"></span>[`$depends`](/docs/api/yii/web/assetbundle/index.md#property-depends) | `array<class-string>` | List of bundle class names that this bundle depends on. Default: `[]`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-exposeGlobal"></span>`$exposeGlobal` | `bool` | Whether to assign the module namespace to `window.bootstrap` for scripts written against the global. Default: `false`. | `BootstrapPluginAsset` |
| <span id="property-js"></span>[`$js`](/docs/api/yii/web/assetbundle/index.md#property-js) | `array<string\|array<array-key, mixed>>` | List of JavaScript files that this bundle contains. Default: `[]`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-jsOptions"></span>[`$jsOptions`](/docs/api/yii/web/assetbundle/index.md#property-jsOptions) | `yii\web\RegisterJsFileOptions` | The options that will be passed to [`View::registerJsFile()`](/docs/api/yii/web/view/index.md#method-registerJsFile) when registering the JS files in this bundle. Default: `[]`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-minified"></span>[`$minified`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#property-minified) | `bool\|null` | Whether to serve the minified files, or `null` to serve them outside debug mode. Default: `null`. | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) |
| <span id="property-publishOptions"></span>[`$publishOptions`](/docs/api/yii/web/assetbundle/index.md#property-publishOptions) | `yii\web\PublishOptions` | The options to be passed to [`AssetManager::publish()`](/docs/api/yii/web/assetmanager/index.md#method-publish) when the asset bundle is being published. Default: `[]`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="property-sourcePath"></span>[`$sourcePath`](/docs/api/yii/web/assetbundle/index.md#property-sourcePath) | `string\|null` | The directory that contains the source asset files for this asset bundle. Default: `null`. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| <span id="method-__construct"></span>[`__construct()`](/docs/api/yii/base/baseobject/index.md#method-__construct) | Constructor. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__call"></span>[`__call()`](/docs/api/yii/base/baseobject/index.md#method-__call) | Calls the named method which is not a class method. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__get"></span>[`__get()`](/docs/api/yii/base/baseobject/index.md#method-__get) | Returns the value of an object property. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__isset"></span>[`__isset()`](/docs/api/yii/base/baseobject/index.md#method-__isset) | Checks if a property is set, i.e. defined and not null. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__set"></span>[`__set()`](/docs/api/yii/base/baseobject/index.md#method-__set) | Sets value of an object property. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-__unset"></span>[`__unset()`](/docs/api/yii/base/baseobject/index.md#method-__unset) | Sets an object property to null. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-canGetProperty"></span>[`canGetProperty()`](/docs/api/yii/base/baseobject/index.md#method-canGetProperty) | Returns a value indicating whether a property can be read. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-canSetProperty"></span>[`canSetProperty()`](/docs/api/yii/base/baseobject/index.md#method-canSetProperty) | Returns a value indicating whether a property can be set. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-className"></span>[`className()`](/docs/api/yii/base/baseobject/index.md#method-className) static | Returns the fully qualified name of this class. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| [`dependencies()`](#method-dependencies) static |  | `BootstrapPluginAsset` |
| <span id="method-hasMethod"></span>[`hasMethod()`](/docs/api/yii/base/baseobject/index.md#method-hasMethod) | Returns a value indicating whether a method is defined. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| <span id="method-hasProperty"></span>[`hasProperty()`](/docs/api/yii/base/baseobject/index.md#method-hasProperty) | Returns a value indicating whether a property is defined. | [`yii\base\BaseObject`](/docs/api/yii/base/baseobject/index.md) |
| [`importJs()`](#method-importJs) | Returns JavaScript that imports the bundle module and runs the given code with the module namespace bound to `bootstrap`. | `BootstrapPluginAsset` |
| [`init()`](#method-init) | Initializes the bundle and forces `type="module"` on its script tag, keeping the other configured options. | `BootstrapPluginAsset` |
| [`moduleUrl()`](#method-moduleUrl) | Returns the bundle script URL exactly as the view registers it, so `import()` evaluates the same module. | `BootstrapPluginAsset` |
| <span id="method-publish"></span>[`publish()`](/docs/api/yii/web/assetbundle/index.md#method-publish) | Publishes the asset bundle if its source code is not under Web-accessible directory. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| <span id="method-register"></span>[`register()`](/docs/api/yii/web/assetbundle/index.md#method-register) static | Registers this asset bundle with a view. | [`yii\web\AssetBundle`](/docs/api/yii/web/assetbundle/index.md) |
| [`registerAssetFiles()`](#method-registerAssetFiles) |  | `BootstrapPluginAsset` |
| <span id="method-registerWith"></span>[`registerWith()`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#method-registerWith) static | Registers the bundle, and its npm-backed dependencies, with the given delivery mode. | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) |
| [`directory()`](#method-directory) protected |  | `BootstrapPluginAsset` |
| [`package()`](#method-package) protected |  | `BootstrapPluginAsset` |
| <span id="method-publishPatterns"></span>[`publishPatterns()`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#method-publishPatterns) protected | Returns additional publish patterns, relative to [`directory()`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#method-directory), for files referenced by the stylesheets. | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) |
| [`scripts()`](#method-scripts) protected |  | `BootstrapPluginAsset` |
| <span id="method-styles"></span>[`styles()`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#method-styles) protected | Returns the stylesheet paths relative to [`directory()`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md#method-directory), without the `.min` infix. | [`AbstractNpmAsset`](/docs/extensions/bootstrap6/reference/asset/abstractnpmasset/index.md) |

## Method details

### dependencies() <span id="method-dependencies"></span>

```php
public static function dependencies(): array
```

**Returns**

`array`

### importJs() <span id="method-importJs"></span>

```php
public function importJs(yii\web\View $view, string $code): string
```

Returns JavaScript that imports the bundle module and runs the given code with the module namespace bound to
`bootstrap`.

The module URL is a JSON string literal safe inside a `<script>` element, with forward slashes kept readable.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$view` | [`yii\web\View`](/docs/api/yii/web/view/index.md) | View the bundle is registered with. |
| `$code` | `string` | JavaScript statements that use the `bootstrap` namespace. |

**Returns**

`string`: JavaScript in the form `import("url").then((bootstrap) => { code });`.

### init() <span id="method-init"></span>

```php
public function init(): void
```

Initializes the bundle and forces `type="module"` on its script tag, keeping the other configured options.

### moduleUrl() <span id="method-moduleUrl"></span>

```php
public function moduleUrl(yii\web\View $view): string
```

Returns the bundle script URL exactly as the view registers it, so `import()` evaluates the same module.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$view` | [`yii\web\View`](/docs/api/yii/web/view/index.md) | View the bundle is registered with. |

**Returns**

`string`: Script URL, including the timestamp query when the asset manager appends one.

**Throws**

- [`yii\base\InvalidConfigException`](/docs/api/yii/base/invalidconfigexception/index.md): if the bundle does not list a script.

### registerAssetFiles() <span id="method-registerAssetFiles"></span>

```php
public function registerAssetFiles(yii\web\View $view): void
```

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$view` | [`yii\web\View`](/docs/api/yii/web/view/index.md) | View that renders the asset files. |

### directory() <span id="method-directory"></span>

```php
protected function directory(): string
```

**Returns**

`string`

### package() <span id="method-package"></span>

```php
protected function package(): string
```

**Returns**

`string`

### scripts() <span id="method-scripts"></span>

```php
protected function scripts(): array
```

**Returns**

`array`