Reputation: 2982
This maybe a very stupid question as PHP is server side programming
But if minifying CSS and minifying Javascript (although they are client side) is a good thing to do to optimise for speed, is there such a thing as minifying PHP and would it have any performance gains on the server?
..or would this simply be a waste of time and effort?
Upvotes: 1
Views: 1149
Reputation: 24661
This would mostly be a waste of time and effort. The biggest reason minifying CSS/JS plays any role at all is the fact that the CSS/JS source code is transmitted across the network. Removing those extra spaces and making function names shorter saves bytes in the transmission.
Since PHP does not get transmitted across the network, there would be no benefit.
You can, however, use PHP to minify the HTML/CSS/Javascript output you send on the fly.
A caveat is something a professor once told me: "Less code tends to run faster".
Upvotes: 4