Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Javascript Packer

Javascript Packer Laravel Package

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.

View on GitHub
Deep Wiki
Context7
Frequently asked questions about Javascript Packer
Can I use meenie/javascript-packer to replace Laravel Mix/Vite for JS minification in a legacy Laravel app?
Yes, but with caveats. This package replaces Mix/Vite’s minification only if your app avoids modern JS features like ES6+ or TypeScript. It’s best for concatenating and minifying pre-transpiled ES5 JS files server-side. For new projects, Laravel Mix or Vite are strongly recommended instead.
How do I integrate this into Laravel’s Blade templates for dynamic JS packing?
Use a custom Blade directive or service provider to inject packed JS. For example, register a `JsPacker` facade in your `AppServiceProvider` and create a directive like `@pack('resources/js/app.js')` to output minified JS. Ensure you whitelist allowed files to prevent XSS risks.
Will this work with Laravel 9+ and PHP 8.1+? Are there compatibility issues?
Potential issues exist due to the package’s age. Test thoroughly, as it may rely on deprecated PHP functions or lack support for newer features like named arguments or attributes. If conflicts arise, fork the package or patch it locally for Laravel 9+ compatibility.
How can I cache packed JS files to avoid repacking on every request?
Leverage Laravel’s cache system (file, Redis, or database) to store packed JS outputs. For example, cache the result of `JsPacker::pack()` with a unique key based on the input file’s hash. Alternatively, pre-pack files during deployment and serve them statically with cache headers.
Does this package support source maps or tree-shaking for debugging?
No, this package only minifies JS using Dean Edwards’ algorithm and does not generate source maps or perform tree-shaking. For debugging, rely on original source files or consider a hybrid approach with modern tools for critical codebases.
Can I use this for runtime JS minification (e.g., packing JS dynamically in middleware)?
Technically yes, but it’s risky for performance. Packing JS on every request increases CPU load and response times. Instead, pre-pack assets during deployment or use middleware sparingly for non-critical, rarely changing scripts. Always cache the output aggressively.
What are the security risks of server-side JS packing in Laravel?
The primary risk is XSS if untrusted JS files are packed. Always whitelist allowed files (e.g., only `resources/js/`) and avoid dynamic file inclusion. Sanitize inputs if using user-provided JS snippets. The package itself has no external dependencies, reducing vulnerability risks.
How does this compare to Laravel Mix or Vite for production performance?
This package will generally perform worse than Laravel Mix/Vite because it lacks modern optimizations like tree-shaking, code splitting, or ES6+ transpilation. However, it may be faster for simple concatenation/minification of small ES5 scripts, as it avoids Node.js overhead. Benchmark with your specific JS bundle.
Is there a way to automate cache busting for packed JS files in Laravel?
No built-in support exists, but you can manually append file hashes or timestamps to output filenames (e.g., `packed-{{ md5('app.js') }}.js`). Alternatively, use Laravel’s `mix-manifest.json` pattern by generating a custom manifest file during deployment.
What should I do if the package stops working due to PHP version updates?
Fork the repository and maintain it locally, as the original package is likely abandoned. Update deprecated PHP functions or dependencies to match your Laravel/PHP version. Consider migrating to a modern alternative like Laravel Mix or ESBuild if long-term maintenance becomes burdensome.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky