PHPackages                             brito101/laravel-minify - 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. brito101/laravel-minify

ActiveLibrary

brito101/laravel-minify
=======================

Minify your blade views, html, css and obfuscate js files on the fly. Lightweight minifier for your Laravel project. Laravel 13 compatible version.

v1.0.0(1mo ago)04↑2900%MITPHPPHP ^8.2 || ^8.3 || ^8.4

Since Apr 5Pushed 1mo agoCompare

[ Source](https://github.com/brito101/laravel-minify)[ Packagist](https://packagist.org/packages/brito101/laravel-minify)[ RSS](/packages/brito101-laravel-minify/feed)WikiDiscussions main Synced 1mo ago

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

Minify for Laravel
==================

[](#minify-for-laravel)

> **Note**: This is a Laravel 13 compatible fork of [fahlisaputra/laravel-minify](https://github.com/fahlisaputra/laravel-minify). All credits to the original author.

Minify for Laravel is a package for minifying and obfuscating Javascript, CSS, HTML and Blade views. It runs automatically when you load a page or view. Increase your website performance on page load and save bandwidth. Obfuscate your Javascript to protect your code from being stolen.

[![Latest Stable Version](https://camo.githubusercontent.com/39b7383e694c1d87c8a233643295164dc32995c7a8c0b4b9917a21f12c978a16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f627269746f3130312f6c61726176656c2d6d696e696679)](https://packagist.org/packages/brito101/laravel-minify)[![Total Downloads](https://camo.githubusercontent.com/6b602a6e8608f3323a734357e6e80f9e3acefcc6cc654483e1aaa4094816725c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f627269746f3130312f6c61726176656c2d6d696e696679)](https://packagist.org/packages/brito101/laravel-minify)[![License](https://camo.githubusercontent.com/991b40acd228ced448f235ad596102f35463a09c925f8579af35bdc42d04fe21/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f627269746f3130312f6c61726176656c2d6d696e696679)](https://github.com/brito101/laravel-minify/blob/main/LICENSE)

Comparison
----------

[](#comparison)

If you minify all your asset files, you can save up to 50% of your bandwidth. This will make your website load faster and save your hosting cost. When you have big files, the difference in size will be even greater.

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

[](#installation)

Minify for Laravel requires PHP 8.2 or higher. This particular version supports Laravel 10.x, 11.x, 12.x, and 13.x.

To get the latest version, simply require the project using [Composer](https://getcomposer.org):

```
composer require brito101/laravel-minify
```

Configuration
-------------

[](#configuration)

Minify for Laravel supports optional configuration. To get started, you'll need to publish all vendor assets:

```
php artisan vendor:publish --provider="Brito101\Minify\MinifyServiceProvider"
```

This will create a config/minify.php file in your app that you can modify to set your configuration. Also, make sure you check for changes to the original config file in this package between releases.

Register the Middleware (Laravel 11 or newer)
---------------------------------------------

[](#register-the-middleware-laravel-11-or-newer)

In order Minify for Laravel can intercept your request to minify and obfuscate, you need to add the Minify middleware to the `bootstrap/app.php` file:

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->web(append: [
        \Brito101\Minify\Middleware\MinifyHtml::class,
        \Brito101\Minify\Middleware\MinifyCss::class,
        \Brito101\Minify\Middleware\MinifyJavascript::class,
    ]);
})
```

Register the Middleware (Laravel 10 or older)
---------------------------------------------

[](#register-the-middleware-laravel-10-or-older)

In order Minify for Laravel can intercept your request to minify and obfuscate, you need to add the Minify middleware to the `app/Http/Kernel.php` file:

```
protected $middleware = [
    ....
    // Middleware to minify CSS
    \Brito101\Minify\Middleware\MinifyCss::class,
    // Middleware to minify Javascript
    \Brito101\Minify\Middleware\MinifyJavascript::class,
    // Middleware to minify Blade
    \Brito101\Minify\Middleware\MinifyHtml::class,
];
```

You can choose which middleware you want to use. Put all of them if you want to minify html, css, and javascript at the same time.

Usage
-----

[](#usage)

This is how you can use Minify for Laravel in your project.

### Minify Asset Files

[](#minify-asset-files)

You must set `true` on `assets_enabled` in the `config/minify.php` file to minify your asset files. If the option set to `false` the route will not registered from service provider. For example:

```
"assets_enabled" => env("MINIFY_ASSETS_ENABLED", true),
```

You can minify your asset files by using the `minify()` helper function. This function will minify your asset files and return the minify designed route. For example:

```

```

```

```

You can modify the assets storage directory path by setting `assets_path` in the `config/minify.php` file. By default, the assets storage directory path is `resources`. For example:

```
"assets_storage" => env("MINIFY_ASSETS_STORAGE", 'resources'),
```

In order to minimize the security risk, the root storage directory is hidden from the public. For the example, you set the `assets_storage` to `storage/app/private/assets` and you want to access the file `test.css` in the `storage/app/private/assets/test.css`. You can use the `minify()` helper function like this:

```

```

The `minify()` helper function will automatically search the file in the `storage/app/private/assets` directory. The result on the browser will be like this:

```

```

The `/storage/app/private/assets` directory is hidden from the public.

### Automatic Insert Semicolon on Javascript or CSS

[](#automatic-insert-semicolon-on-javascript-or-css)

Use this option if Minify for Laravel makes your javascript or css not working properly. You can enable automatic insert semicolon on javascript or css by setting `true` on `insert_semicolon` in the `config/minify.php` file. For example:

```
"insert_semicolon" => [
    'css' => env("MINIFY_CSS_SEMICOLON", true),
    'js' => env("MINIFY_JS_SEMICOLON", true),
],
```

Caution: this option is experimental. If the code still not working properly, you can disable this option and add semicolon manually to your Javascript or CSS code.

### Skip LD+JSON Script Minification

[](#skip-ldjson-script-minification)

You can configure Minify for Laravel to automatically skip minification of `` tags by setting `skip_ld_json` to `true` in the `config/minify.php` file. This is enabled by default to preserve structured data for SEO purposes. For example:

```
"skip_ld_json" => env("MINIFY_SKIP_LD_JSON", true),
```

When enabled, scripts like this will not be minified:

```

{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "My Company",
  "url": "https://example.com"
}

```

### Skip Minify on Blade

[](#skip-minify-on-blade)

You can skip minify on blade by using attribute `ignore--minify` inside script or style tag. For example:

```

    /* css */

   /* javascript */

```

### Skip Minify when Rendering View

[](#skip-minify-when-rendering-view)

You can skip minify when rendering view by passing `ignore_minify = true` in the view data. For example:

```
return view('welcome', ['ignore_minify' => true]);
```

### Skip Minify by Route

[](#skip-minify-by-route)

You can skip minify by route by adding the route name to the `ignore` array in the `config/minify.php` file. For example:

```
"ignore" => [
    '/admin'
],
```

### Custom Directives Replacement

[](#custom-directives-replacement)

You can replace custom directives by adding the directive name to the `directives` array in the `config/minify.php` file. For example in AlpineJS you can write `@click="function()"`. Unfortunately, Minify for Laravel will remove the `@` symbol. You can replace it by adding `@ => x-on:` to the `directives` array. For example:

```
"directives" => [
    '@' => 'x-on:',
],
```

### Keep Directives

[](#keep-directives)

You can keep directives by adding the directive name to the `keep_directives` array in the `config/minify.php` file. For example when you use `@vite`, you can add `@vite` to the `keep_directives` array. For example:

```
"keep_directives" => [
    '@vite'
],
```

Known Issues
------------

[](#known-issues)

- Minify for Laravel will remove the `@` symbol in the blade file. This will make the blade directive not working properly. You can fix this by adding `@ => x-on:` to the `directives` array in the `config/minify.php` file.
- Does not support for some Javascript framework. You can try experiment by changing the `insert_semicolon` option to `true` or `false` in the `config/minify.php` file.

Contributing
------------

[](#contributing)

If you find an issue, or have a better way to do something, feel free to open an issue, or a pull request. The package is far from perfect, and any help is welcome. There are no formal contribution guidelines, and there should be no contribution too small. All coding styles will be fixed during the pull request by StyleCI. So, don't worry too much about the code style. We'd love to hear from you!

Contributors
------------

[](#contributors)

### Original Package Contributors

[](#original-package-contributors)

Big thanks to the people who have contributed to the original package:

[ ![](https://camo.githubusercontent.com/104a305234b0e73ef7c72db61ec68153cda430157e77d6bab94e6b616a275eb2/68747470733a2f2f636f6e747269622e726f636b732f696d6167653f7265706f3d6661686c69736170757472612f6c61726176656c2d6d696e696679)](https://github.com/fahlisaputra/laravel-minify/graphs/contributors)and [@SaeedHeydari](https://github.com/SaeedHeydari)

License
-------

[](#license)

Laravel Minify is licensed under the [MIT license](LICENSE).

Original Author
---------------

[](#original-author)

Original package by [fahlisaputra](https://github.com/fahlisaputra)

Support
-------

[](#support)

If you are having general issues with this package, feel free to contact us on

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance91

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/994111cfd0972ef1a1579735336401fd6d82e4ea9e21f23fb26db22dcba08da6?d=identicon)[brito101](/maintainers/brito101)

---

Top Contributors

[![brito101](https://avatars.githubusercontent.com/u/13372886?v=4)](https://github.com/brito101 "brito101 (3 commits)")

---

Tags

laravelhtml minifiercss-minifierjs-minifierjs-obfuscatelaravel13

### Embed Badge

![Health badge](/badges/brito101-laravel-minify/health.svg)

```
[![Health](https://phpackages.com/badges/brito101-laravel-minify/health.svg)](https://phpackages.com/packages/brito101-laravel-minify)
```

###  Alternatives

[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[fahlisaputra/laravel-minify

Minify your blade views, html, css and obfuscate js files on the fly. Lightweight minifier for your Laravel project.

150157.0k1](/packages/fahlisaputra-laravel-minify)[laravel/pulse

Laravel Pulse is a real-time application performance monitoring tool and dashboard for your Laravel application.

1.7k12.1M99](/packages/laravel-pulse)[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9712.1M97](/packages/roots-acorn)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

266778.4k3](/packages/laravel-cashier-paddle)

PHPackages © 2026

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