2

只需看看Ask.com主页源。这是一条很长的线。

如何从最终的 html 输出中删除换行符和其他不必要的代码?(Views内容)

例如:

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

至:

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

GZip可以做到吗?

4

2 回答 2

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/

于 2012-08-09T05:11:00.857 回答
1

您可以在这篇面包店文章中使用助手:http: //bakery.cakephp.org/articles/tiutalk/2010/07/09/output-valid-and-clean-x-html-with-tidyhelper

要将所有内容集中在一条线上,您可以替换

return $output;

return preg_replace('/\r?\n/m', '', $output);
于 2012-08-08T18:46:32.957 回答