meenie/javascript-packer
PHP library for packing and minifying JavaScript using Dean Edwards’ Packer algorithm. Compresses JS to reduce size and improve load times, with simple PHP API for integrating into builds or runtime processing in Laravel and other projects.
elixir/mix for JS concatenation/minification via custom service providers or Blade directives.JsPacker facade or standalone class to process JS files on-the-fly (e.g., via middleware or Blade @pack directives).resources/js/).file, redis) to store packed assets.mix.js() or elixir.js() with custom Blade directives or a facade (e.g., JsPacker::pack('app.js')).PackJsMiddleware to auto-pack JS for non-cached requests (risky; prefer opt-in).// app/Providers/JsPackerServiceProvider.php
public function boot() {
Blade::directive('pack', function ($expr) {
return "<?php echo app('jsPacker')->pack({$expr}); ?>";
});
}
config/js-packer.php).import() or module syntax).app.js) with the packer, test in staging.@pack('file.js').storage/app/public/js/ with hashed filenames).post-update hook in CI/CD to trigger repacking on JS changes.import/export), dynamic imports, or JSX.import().file_get_contents() and eval() permissions are allowed (for dynamic packing).composer require meenie/javascript-packer).php artisan vendor:publish --tag=js-packer-config).config/app.php.@include directives with @pack in Blade.PackedJsCache class).composer.json.create_function() removed in PHP 7.2).config/js-packer.php.try-catch packing process).open_basedir restrictions.console.log or a linter.Cache-Control headers (e.g., max-age=31536000).| Failure Scenario | Impact | Mitigation |
|---|---|---|
PHP eval() disabled |
Packing fails silently | Use a fallback to serve original JS files. |
| Malformed |
How can I help you explore Laravel packages today?