Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option for safe minification only? #225

Closed
peixotorms opened this issue Dec 21, 2017 · 2 comments
Closed

Option for safe minification only? #225

peixotorms opened this issue Dec 21, 2017 · 2 comments

Comments

@peixotorms
Copy link

Hi there,

I usually have to minify lots of different js files from different origins, and what I notice is that sometimes PHP Minify breaks some JS code.

Is there a way to only select "safe optimizations", such as white space only, while preserving all code as it is?

@matthiasmullie
Copy link
Owner

Alas, there is no such option.

Whitespace stripping is probably one of the hardest (and most error prone) optimizations the minifier does anyway, as it must be kept inside strings & regular expressions, when it serves as ASI, inside CSS calc statements, ...
I'd hardly call it a safe optimization :)

If you do run into minify issues, please submit issues for all of them, and I'll work on resolving them in a timely manner :)

@peixotorms
Copy link
Author

What I had in mind, is something along the lines of Closure Compiler, whitespace only removal.
https://closure-compiler.appspot.com/home

By safe, I meant to say, no text replacements, such as black to #000 (#316) or replacing function names or variables with shorten versions.

It would be great if somehow you can take care of the white space first and have a return option there, before proceeding to the text code replacements. That way, we could preserve the code as it is and remove only the white space.

Being safe or not is another matter, but it's probably safer to just remove the white space than to change code and variable names / values, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants