PHPackages                             cbl/blade-script - 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. [Templating &amp; Views](/categories/templating)
4. /
5. cbl/blade-script

ActiveLibrary[Templating &amp; Views](/categories/templating)

cbl/blade-script
================

v1.1(2y ago)4818.3k52MITPHPCI failing

Since Jun 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/cbl/blade-script)[ Packagist](https://packagist.org/packages/cbl/blade-script)[ RSS](/packages/cbl-blade-script/feed)WikiDiscussions master Synced today

READMEChangelog (10)Dependencies (3)Versions (12)Used By (2)

Blade Script
============

[](#blade-script)

A package to easily add transpiled &amp; minified scripts to your blade components.

```
{{ $slot }}

function myFunction() {
    // Do something.
}

```

Introduction
------------

[](#introduction)

In case you want to add javascript functionality to a blade component, you can write it directly in the script tag. However, the script will then not be minified and if a component is used multiple times, the script tag will also be included multiple times.

Blade Script solves these problems. The javascript code can be minified in production and each script tag is only included once all without running a compiler separately. Also only required scripts are included.

Additionally there is the possibility to add transpilers like [babel](https://babeljs.io/).

Installation
------------

[](#installation)

The package can be easily installed via composer.

```
composer require cbl/blade-script
```

Now the necessary assets must be published. This includes the script.php config and the storage folder where the compiled scripts are stored.

```
php artisan vendor:publish --provider="BladeScript\ServiceProvider"
```

Include Scripts
---------------

[](#include-scripts)

The blade component `x-scripts` includes all required scripts, so it may be placed at the very bottom of your **body**.

```

    ...

```

Usage
-----

[](#usage)

Each blade component can contain exactly one `x-script` component. Your scripts can then be written inside the wrapper like so.

```
{{ $slot }}

myFunction() {
    // Do something.
}

```

Optimizing Scripts
------------------

[](#optimizing-scripts)

Blade scripts share the same behavior as Views. As suggested in the [View documentation](https://laravel.com/docs/7.x/views#optimizing-views), the `script:cache` command can be added to your deployment workflow to ensure that all scripts are compiled and thus improve performance.

```
php artisan script:cache
```

You may use the `script:clear` command to clear the script cache:

```
php artisan script:clear
```

Write Transpiler
----------------

[](#write-transpiler)

You can easily add transpilers to the compiler, the following example explains how to create and include a transpiler.

First you have to create a transpiler class that implements the `BladeScript\Contracts\Transpiler` contract.

```
namespace BladeBabel;

use Babel\Transpiler as Babel;
use BladeScript\Contracts\Transpiler;

class BabelTranspiler implements Transpiler
{
    public function transpile($script)
    {
        return Babel::transform($script);
    }
}
```

The transpiler can now be added to the compiler in your service provider like so:

```
namespace BladeBabel;

use Illuminate\Support\ServiceProvider;

class BabelServiceProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->afterResolving('script.compiler', function ($compiler) {
            $compiler->addTranspiler(new BabelTranspiler);
        });
    }
}
```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity33

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 85.2% 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 ~142 days

Recently: every ~354 days

Total

11

Last Release

783d ago

Major Versions

v0.1.4 → v1.0.02020-08-25

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/29352871?v=4)[Lennart Carstens-Behrens](/maintainers/cbl)[@cbl](https://github.com/cbl)

---

Top Contributors

[![cbl](https://avatars.githubusercontent.com/u/29352871?v=4)](https://github.com/cbl "cbl (23 commits)")[![lpheller](https://avatars.githubusercontent.com/u/36259611?v=4)](https://github.com/lpheller "lpheller (3 commits)")[![jannescb](https://avatars.githubusercontent.com/u/17292622?v=4)](https://github.com/jannescb "jannescb (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/cbl-blade-script/health.svg)

```
[![Health](https://phpackages.com/badges/cbl-blade-script/health.svg)](https://phpackages.com/packages/cbl-blade-script)
```

###  Alternatives

[pimcore/pimcore

Content &amp; Product Management Framework (CMS/PIM/E-Commerce)

3.8k3.8M508](/packages/pimcore-pimcore)[appwrite/sdk-generator

SDK generator for Appwrite APIs across multiple programming languages and platforms

322207.2k3](/packages/appwrite-sdk-generator)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.1k17.8k](/packages/prestashop-prestashop)[elgg/elgg

Elgg is an award-winning social networking engine, delivering the building blocks that enable businesses, schools, universities and associations to create their own fully-featured social networks and applications.

1.7k16.4k79](/packages/elgg-elgg)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[sebastienheyd/boilerplate

Laravel Boilerplate based on AdminLTE 3 with blade components, user management, roles, permissions, logs viewer, ...

29420.2k3](/packages/sebastienheyd-boilerplate)

PHPackages © 2026

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