Question

I've been looking around SO for a JavaScript obfuscation script of some kind, note that I'm not looking for a compressor, I need an obfuscation script/code that will shrink the JavaScript files I have in PHP (not in JavaScript) for production reasons.

I've heard about Minify, I've used it a couple times, works great but it doesn't obfuscate my JS code, simply that is all I need to have, think like the Dean Edwards packer but without packing it, just the shrink variables mode in PHP instead of JS.

EDIT: My mistake, I understood "obfuscate" wrongly, I mean minification on the JS code - shrinking variable names and removing whitespace, etc. Minify is the closest I got to, but it does not shrink variables.

Is there one out there?

Was it helpful?

Solution

exec('java.exe -jar compiler.jar --js pre.js --manage_closure_dependencies true --js_output_file end.js');

exec('java.exe -jar yuicompressor.jar pre.js  -o end.js');

use:

google closure compiler AND http://developer.yahoo.com/yui/compressor/

OTHER TIPS

Our ECMAScript Obfuscator probably does what you want. In particular, it will find JavaScript chunks in PHP files and obfuscate/minify depending on what you want.

I'm pretty sure this is what you're looking for. And I dont' know if you'll be able to find a solution that does it better than Google: http://code.google.com/speed/articles/compressing-javascript.html

I know this is an old question -- but it needs an updated answer, as there are now PHP implementations of jsMin

eg: http://wonko.com/post/a_faster_jsmin_library_for_php

Note: When you say "shrink variables" it's important to clarify: Most minifiers will only shrink local variables within functions, but leave globals and function names -- as renaming those would likely break interoperability with the page / DOM elements / other scripts, etc.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top