class Script (View source)

Manage JavaScript asset bundles.

In addition to files, you can also add callbacks which return JS code.

Waterhole will simply concatenate the scripts together into bundles. You are responsible for doing any transpiling prior.

Traits

Manage a list of assets grouped into bundles.

Constants

CACHE_KEY

FILE_EXTENSION

Methods

static void
add(string $file, string $bundle = 'default')

Add an asset to a bundle.

static array
urls(array $bundles)

Compile the given bundles and return their URLs.

static void
flush()

Flush all bundles so they are regenerated on the next request.

static void
flushBundle(string $bundle)

Flush a specific bundle so that is it regenerated on the next request.

Details

static void add(string $file, string $bundle = 'default')

Add an asset to a bundle.

The default and default-{locale} bundles are loaded on every page that uses the Waterhole layout. The cp and cp-{locale} bundles are loaded on pages in the Control Panel.

Parameters

string $file
string $bundle

Return Value

void

static array urls(array $bundles)

Compile the given bundles and return their URLs.

Parameters

array $bundles

Return Value

array

static void flush()

Flush all bundles so they are regenerated on the next request.

Return Value

void

static void flushBundle(string $bundle)

Flush a specific bundle so that is it regenerated on the next request.

Parameters

string $bundle

Return Value

void