Compressing a HTML page in php in very simple to implement especially if you use a content management system for your website.

 

 

 

And that’s it at it’s very basic!

warning This function will not compress commented JavaScript, it will compress the JavaScript that’s not commented. For JavaScript compression it is best to serve the JavaScript from external files and compressed with either JavaScriptPacker.php or YUI compressor. CSS compression can be further done with another compression function and I will show this in another tutorial.