2

Just take a look at Ask.com homepage source. It's one long line.

How to remove line-breaks and other unnecessary codes from final html output? (Views content)

forexample:

<div id="test">
    <span>Hello World!</span>
</div>

to:

<div id="test"><span>Hello World!</span></div>

Can GZip do it?

mrdaliri
  • 7,148
  • 22
  • 73
  • 107
  • possible duplicate of [Html minification?](http://stackoverflow.com/questions/728260/html-minification) – jman Aug 08 '12 at 18:16
  • no, I ask for CakePHP, not for normal PHP. I want to know where can I put my minification function to minify whole output. – mrdaliri Aug 08 '12 at 18:17
  • Unless you're Google and have millions of hits every day I don't know why you would want to do this. We're talking a few bytes saved AFTER gzipping the stream. – Razor Aug 09 '12 at 11:44

2 Answers2

3

I haven't had time to implement this myself yet however this helper looks good.

https://github.com/plyst/cakephp-minifyhtml-plugin

You can also use the following to minify the rest of your assets

https://github.com/markstory/asset_compress/

CoryJThompson
  • 333
  • 1
  • 8
1

You may use the helper in this bakery article: http://bakery.cakephp.org/articles/tiutalk/2010/07/09/output-valid-and-clean-x-html-with-tidyhelper

To get it all on one line, you may replace

return $output;

with

return preg_replace('/\r?\n/m', '', $output);
tigrang
  • 6,767
  • 1
  • 20
  • 22