PHPackages                             morningtrain/enqueuer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. morningtrain/enqueuer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

morningtrain/enqueuer
=====================

Laravel package to enqueue css and js files for load. It supports dependencies, caching and passing data to scripts from PHP.

1.2.6(9y ago)4170GNU GPL v3.0PHPPHP &gt;=5.3.0

Since Dec 12Pushed 9y ago3 watchersCompare

[ Source](https://github.com/Morning-Train/laravel-enqueuer)[ Packagist](https://packagist.org/packages/morningtrain/enqueuer)[ Docs](https://github.com/morningtrain/laravel-enqueuer)[ RSS](/packages/morningtrain-enqueuer/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (3)Versions (11)Used By (0)

enqueuer
========

[](#enqueuer)

[![Software License](https://camo.githubusercontent.com/d4dd9e8b2c8a5143f82a9688d61eb58e7aeda127e8e770c411785931163b8137/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e63652d253230474e5525323047656e6572616c2532305075626c69632532304c6963656e736525323076332e302d627269676874677265656e2e737667)](LICENSE.md)[![](https://camo.githubusercontent.com/0ba9894dd1bdbe528a13b33a61e14b9808269deaa9933691989cbc72f3dcd036/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e322e362d627269676874677265656e2e737667)](https://camo.githubusercontent.com/0ba9894dd1bdbe528a13b33a61e14b9808269deaa9933691989cbc72f3dcd036/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f76657273696f6e2d312e322e362d627269676874677265656e2e737667)

Laravel package to enqueue css and js files for load. It supports dependencies, to serve files in the correct order, caching, magic methods and passing along PHP variables.

Install
-------

[](#install)

Via Composer

```
$ composer require morningtrain/enqueuer
```

Add this service provider to your config/app.php file.

```
morningtrain\enqueuer\enqueuerServiceProvider::class,
```

Usage
-----

[](#usage)

In all of the below cases, "Admin" can be any word and is used to group styles and scripts. A common use case is to have different scripts in admin and frontend.

### To enqueue a script or style

[](#to-enqueue-a-script-or-style)

```
Enqueuer::addAdminScript('jquery', [
	'location' => 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
]);

Enqueuer::addAdminScript('sample', [
	'content' => "console.log('sample');",
	'dependencies' => ['jquery']
]);
```

The syntax for adding styles and scripts are almost the same. The main difference is that you would call "addAdminStyle" in the above example instead. In addition, note that it is not possible to use the data property with styles.

### Script dependencies

[](#script-dependencies)

Some scripts and styles might be dependent on others. To solve this, one can add the dependencies property. The value of this property is an array that contains the names of all the script/styles it is dependent on. The scripts/styles will be sorted according to the dependencies.

```
Enqueuer::addAdminScript('sample', [
	'content' => "console.log('sample');",
	'dependencies' => ['jquery']
]);

Enqueuer::addAdminScript('jquery', [
	'location' => 'https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js'
]);
```

### Pass PHP data to script

[](#pass-php-data-to-script)

It is possible to pass on a data object to a script by including the data properties.

The value of data is an array containing the name of the object and the properties.

```
Enqueuer::addProfileScript('config_test', [
	'content' => "console.log(config.baseUrl);",
	'data' => [
		'object' => 'config',
		'properties' => [
			'baseUrl' => url('')
		]
	]
]);
```

### Including script and styles in views

[](#including-script-and-styles-in-views)

To include scripts in view

```
{!! Enqueuer::getAdminScripts() !!}
```

To include styles in view

```
{!! Enqueuer::getAdminStyles() !!}
```

### Cache control

[](#cache-control)

#### Clear all caches

[](#clear-all-caches)

Clear everything

```
Enqueuer::clearAllCache();
```

To clear all caches for scripts

```
Enqueuer::clearScriptsCache();
```

To clear all caches for styles

```
Enqueuer::clearStylesCache();
```

To clear all caches for scripts in group (admin in this case)

```
Enqueuer::clearAdminScriptsCache();
```

To clear all caches for styles in group (admin in this case)

```
Enqueuer::clearAdminStylesCache();
```

### Managing settings

[](#managing-settings)

Settings can be overwritten at any time using this snippet:

```
Enqueuer::configure([
	'cacheScripts' => true,
	'cacheStyles' => true,
	'alwaysGenerateStylesCache' => false,
	'alwaysGenerateScriptsCache' => false,
	'storageDisk' => 'public'
]);
```

It allows for enabling / disabling cache for scripts and styles, as well as allowing the cache for being regenerated on every request. Note, that in order to use it without caching, all enqueued scripts have to be publicly available on the provided url.

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Morning Train](https://morningtrain.dk)

License
-------

[](#license)

GNU General Public License v3.0. Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~48 days

Total

10

Last Release

3645d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/278725?v=4)[morningtrain](/maintainers/morningtrain)[@morningtrain](https://github.com/morningtrain)

---

Top Contributors

[![bjarnebonde](https://avatars.githubusercontent.com/u/5835042?v=4)](https://github.com/bjarnebonde "bjarnebonde (29 commits)")

---

Tags

laravelcssJSmorningtrainenqueuer

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/morningtrain-enqueuer/health.svg)

```
[![Health](https://phpackages.com/badges/morningtrain-enqueuer/health.svg)](https://phpackages.com/packages/morningtrain-enqueuer)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[renatomarinho/laravel-page-speed

Laravel Page Speed

2.5k1.7M11](/packages/renatomarinho-laravel-page-speed)[vinkius-labs/laravel-page-speed

Laravel Page Speed

2.5k9.6k1](/packages/vinkius-labs-laravel-page-speed)[emargareten/inertia-modal

Inertia Modal is a Laravel package that lets you implement backend-driven modal dialogs for Inertia apps.

90128.1k](/packages/emargareten-inertia-modal)[tarunkorat/laravel-asset-cleaner

Safely detect and remove unused CSS, JS, SCSS and other assets from Laravel applications

735.0k1](/packages/tarunkorat-laravel-asset-cleaner)[fisharebest/laravel-assets

Asset management for Laravel

208.1k](/packages/fisharebest-laravel-assets)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
