Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
625a37c
feat: create new option to configure build storage
fahlisaputra Feb 24, 2025
1482247
feat: implement build cache for the assets
fahlisaputra Feb 24, 2025
77e738b
feat: implement cache check on the helper
fahlisaputra Feb 24, 2025
94484c5
Merge branch 'main' into feature/caching
fahlisaputra Feb 24, 2025
4330720
Apply fixes from StyleCI
StyleCIBot Feb 24, 2025
717d1bb
Merge pull request #36 from fahlisaputra/analysis-maAl9E
fahlisaputra Feb 24, 2025
131dbbc
Laravel 12 support
oriceon Feb 26, 2025
df00ac9
Merge pull request #37 from oriceon/patch-1
fahlisaputra Feb 27, 2025
c55ebb6
docs: Add support for Laravel 12
fahlisaputra Feb 27, 2025
849343a
Update and rename README.md to docs: Laravel 12 support and contributors
fahlisaputra Feb 27, 2025
4374dcf
docs: Laravel 12 support and contributors
fahlisaputra Feb 27, 2025
f3e4fdf
feat: skip minify for LD+JSON
StephaneBour Jun 23, 2025
6a19886
Merge pull request #40 from StephaneBour/main
fahlisaputra Jul 7, 2025
3ecc512
chore: remove unused IDE configuration and update dependencies in com…
fahlisaputra Nov 26, 2025
3e09afc
Merge branch 'feature/caching' of github.com:fahlisaputra/laravel-min…
fahlisaputra Nov 26, 2025
a69955d
chore: remove unused helper classes and refactor provider and config …
fahlisaputra Nov 26, 2025
a1e6253
chore: update composer.json to set minimum-stability to stable
fahlisaputra Nov 26, 2025
35648ef
chore: enhance JS minification middleware with backward-compatible co…
fahlisaputra Nov 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .idea/laravel-idea.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 0 additions & 10 deletions .idea/laravel9-html-minifier-main.iml

This file was deleted.

2 changes: 1 addition & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 62 additions & 1 deletion .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 33 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@



<img width="150" src="assets/minify_logo.svg" alt="Logo">

# Minify for Laravel
Expand All @@ -24,7 +23,7 @@ If you minify all your asset files, you can save up to 50% of your bandwidth. Th

## Installation

Minify for Laravel requires PHP 7.2 or higher. This particular version supports Laravel 8.x, 9.x, 10.x, and 11.x.
Minify for Laravel requires PHP 7.2 or higher. This particular version supports Laravel 8.x, 9.x, 10.x, 11.x, and 12.x.

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

Expand All @@ -46,8 +45,8 @@ In order Minify for Laravel can intercept your request to minify and obfuscate,
```php
->withMiddleware(function (Middleware $middleware) {
$middleware->web(append: [
\Fahlisaputra\Minify\Middleware\MinifyHtml::class,
\Fahlisaputra\Minify\Middleware\MinifyCss::class,
\Fahlisaputra\Minify\Middleware\MinifyHtmlMiddleware::class,
\Fahlisaputra\Minify\Middleware\MinifyCssMiddleware::class,
\Fahlisaputra\Minify\Middleware\MinifyJavascript::class,
]);
})
Expand All @@ -60,11 +59,11 @@ In order Minify for Laravel can intercept your request to minify and obfuscate,
protected $middleware = [
....
// Middleware to minify CSS
\Fahlisaputra\Minify\Middleware\MinifyCss::class,
\Fahlisaputra\Minify\Middleware\MinifyCssMiddleware::class,
// Middleware to minify Javascript
\Fahlisaputra\Minify\Middleware\MinifyJavascript::class,
// Middleware to minify Blade
\Fahlisaputra\Minify\Middleware\MinifyHtml::class,
\Fahlisaputra\Minify\Middleware\MinifyHtmlMiddleware::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.
Expand Down Expand Up @@ -122,6 +121,26 @@ Use this option if Minify for Laravel makes your javascript or css not working p
```
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
You can configure Minify for Laravel to automatically skip minification of `<script type="application/ld+json">` 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:

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

When enabled, scripts like this will not be minified:

```html
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "Organization",
"name": "My Company",
"url": "https://example.com"
}
</script>
```

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

Expand Down Expand Up @@ -178,9 +197,15 @@ You can keep directives by adding the directive name to the `keep_directives` ar

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!

## Thanks
## Contributors
Big thanks to the people who have contributed to this package:
- [@SaeedHeydari](https://github.com/SaeedHeydari)

<a href="https://github.com/fahlisaputra/laravel-minify/graphs/contributors">
<img src="https://contrib.rocks/image?repo=fahlisaputra/laravel-minify" />
</a>


and [@SaeedHeydari](https://github.com/SaeedHeydari)

## License
Laravel Minify is licensed under the [MIT license](LICENSE).
Expand Down
12 changes: 7 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
}
],
"require": {
"php": "^7.2.5 || ^8.0 || ^8.1 || ^8.2 || ^8.3",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/http": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0",
"illuminate/view": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0"
"php": "^8.0 || ^8.1 || ^8.2 || ^8.3 || ^8.4",
"illuminate/support": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/http": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"illuminate/view": "^6.0 || ^7.0 || ^8.0 || ^9.0 || ^10.0 || ^11.0 || ^12.0",
"ext-dom": "*",
"ext-libxml": "*"
},
"license": "MIT",
"autoload": {
Expand All @@ -29,7 +31,7 @@
"Fahlisaputra\\Minify\\": "src/"
}
},
"minimum-stability": "dev",
"minimum-stability": "stable",
"prefer-stable": true,
"extra": {
"laravel": {
Expand Down
Loading