[英]How to compress HTML output except on a certain div?
I'd like to use this function: 我想使用这个功能:
ob_start('no_returns');
function no_returns($a) {
return str_replace(
array("\r\n","\r","\n","\t",'','',''),
'', $a);
}
But when I do, it completely kills Disqus comments so I'd like to ignore the DIV "disqus_thread". 但是当我这样做时,它完全杀死了Disqus评论,所以我想忽略DIV“disqus_thread”。 How would I go about doing that without using some heavy search? 如果不使用大量搜索,我该怎么做呢?
If you are looking to speed up the download of the web page, you might try another method: 如果您希望加快网页下载速度,可以尝试其他方法:
<?php
ob_start('ob_gzhandler');
// html code here
This will compress the output in a much more efficient manner and your browser will automatically decompress the output in real-time before the visitor sees it. 这将以更有效的方式压缩输出,并且您的浏览器将在访问者看到之前实时自动解压缩输出。
A related thread on-line is here: http://bytes.com/topic/php/answers/621308-compress-html-output-php 一个相关的在线线程在这里: http : //bytes.com/topic/php/answers/621308-compress-html-output-php
(This is the PHP way to compress web pages without using the webserver configuration. For example apache+gzip/mod_deflate on apache as mentioned above) (这是在不使用Web服务器配置的情况下压缩网页的PHP方法。例如,如上所述,apache上的apache + gzip / mod_deflate)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.