I am using PHP for creating some dynamic websites. I have coming across various optimization techniques to optimie my web pages. One among them is HTML compression. Since my web page is having lots of JS, CSS and inline scripts in it. The total size of generated source(HTML) is coming around 150KB.
But if i save the generated page source, and compress it using some sites like http://htmlcompressor.com/compressor.html, the output file is coming around 90KB(where empty line breaks and space are removed). So is there any way to do this dynamically when the page is generated? Is there any helpers or library available for that? Any help on this topic would be greatly appreciated.
One of the best things you can do is remove any inline scripts that don't need to be inline.
I have this at the top of my PHP file:
Then I include this function: (My notes don't say where I stole it from)
At the very bottom of the page, I just call:
As the code says, if you have already sent headers -- if you've already sent ANY output, basically, then this code not compress anything for you.