Reputation: 11574
This question refers to performance, not to file size.
I know there are "min" files for javascript and css, but what about optimizing PHP scripts. Of course you will want to keep a copy of the scripts in human readable format. However, for the version running on the production server, will it perform better if it is "optimized" by removing all of the unecessary space and newline / tab characters?
Any benchmarks on this?
Upvotes: 14
Views: 4387
Reputation: 272537
I would place money on the hypothesis that the tiny amount of extra work that the lexer needs to do in order to skip the whitespace is utterly negligible compared to the actual job of parsing interpreting the rest of the source code.
Upvotes: 7
Reputation: 8814
JavaScript, html and css are usually minified because they are transfered, which is much, much slower than processor speed. Minifying makes a huge difference.
For php parser, removing white spaces makes a so small difference that it's not taken into account, even with thousands parses. There are so many other things that have greater impact over performance, that you shouldn't worry about this one.
Upvotes: 4
Reputation: 850
JS- and CSS-Files are minimized for download time - not for interpretation speed.
I think the difference in interpretation time with or without whitespaces is negligible.
However, if you are into optimizing the speed of your scripts, have a look at Hip-Hop.
Upvotes: 3
Reputation: 3710
This has already been discussed some via another question here that you might want to look at: php source code whitespace
Also, while I've never personally made use of it, there appears to be a command "php -w" which removes all whitespace and comments for you, should you want to go that route.
Upvotes: 13