I am familiar with the concept of minification in Javascript and how whitespaces contribute to JS file sizes, but does that concept not apply to PHP scripts?
does whitespace make php scripts file sizes larger? can we minify php scripts? or is there no point in doing so because whitespaces in source codes in php does not affect anything at all?
There's no point in doing so because users don't download your PHP file. There's no need to minify server-side scripts.
There is a small gain in speed, if you have optimized whitespace in PHP files (reading in and compiling the file), but it is, compared to the rest, insignificant (that said, you can gain more rewriting all unnecessary 'preg_replace' with the appropriate string methods).
Actually, there are possibilities to precompile a PHP file and present this optimized code to the PHP interpreter. Search for Zend Encoder or IonCube. But then, the source file is no more human-readable.
For JS files the gain in speed stems almost to 100% from the smaller loading time via HTTP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With