0

I know JavaScript or CSS for expample can be "compressed", "simplified" in order to be loaded faster. After simplifying they are difficult to be read by humans... and this is exactly what I need.
Is there anyway to make it automatically? Rename all variables to short random strings and make it all hypercompressed. I don't think it is a fool thing because I have seen this lot of times in javascript. The idea is to conserve the original source and upload the minified one.

2 Answers 2

4

There is no need for doing this. The Server reads the file, and the file never gets transferred to the user.

Therefore, compression is useless because there is no bandwidth saved.

CSS & JavaScript does however get transfered to the user, and therefore they can see it. A user can never see PHP unless you've done something wrong on your server. But then you need to worry about totally different things than compression.

Sign up to request clarification or add additional context in comments.

12 Comments

CSS and JS can bee seen from clients side. PHP can't. At least normaly not.
@Fluffeh the question was about PHP compression, not CSS & JavaScript. But I clarified it based on Dainis comment
@DainisAbols Yes, I know... but. What if others have access to my php files? What could be a good way to make it unintelligible for them?
@Kenedy Wait you were being serious? The only way would be security through obscurity, but that never works despite a cult following. As you said before computer were humans and humans made the machine and the scripts that run on it as such humans will always understand its flaws
@Kenedy One last thing, if you were to code obscurely then base64 Obfuscation you could make a persons life hell without a considerable amount of time, I guess thats the key really; make it so time consuming to read your script that they just cant be bothered and give up
|
2

If you want to compress it, this is basically useless, since you have it on the server and only the output gets transferred to the client.

If you want to make the code more difficult to read for other human beings, you're looking for something which is called an obfuscator.

There are a few php obfuscator engines out there, p.e.

3 Comments

Can anyone give me a good example of when/why you would want to obfuscate your code?
@RobForrest Imagine you want to host it on one elses server (not my case). That was it! Thanks! Great answer.
@RobForrest Next time my boss or any of my co-workers whine about how hard it is to read my perfectly indented, clean and commented code I'm sending them the obfuscated version. =] Very handy to have an obfuscator around.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.