使用php压缩html输出? [英] compress html output with php?

查看:83
本文介绍了使用php压缩html输出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨我知道

ob_start(''ob_gzhandler'');

但我正在寻找能够删除所有换行符和额外的东西
html中的
空格,然后将其发送到访问者的浏览器。这可能是

吗?


干杯,
$ b $bCiarán

解决方案




这个评论有一个剥离空白的例子:

http://ru.php.net/manual/en/function.ob-start .php#71953

3月22日9:48 pm,Ciaran < cronok ... @ hotmail.comwrote:


HI我知道

ob_start(''ob_gzhandler'');

但我正在寻找一些东西,在将它发送到访问者的浏览器之前删除html中的所有换行符和额外的

空格。这可能是

吗?


干杯,
$ b $bCiarán



嗯,是的看起来不错。非常感谢彼得。


有谁知道它是否值得?我的意思是运行

的时间少于下载更长的
html文件所需的时间?对此有何看法?


干杯,
$ b $bCiarán


好的我跑了在我最慢的页面上进行一些测试...这是我的结果:


没有压缩功能:::::::::::

页面大小:523.97 kb

加载时间:0.9995秒

加载时间:0.8秒

加载时间:0.8095秒

加载时间:0.7091秒

加载时间:0.7223秒

WITH COMPRESSION FUNCTION :::::::::::: br / >
页面大小:494.77 kb

加载时间:0.8448秒

加载时间:0.8307秒

加载时间:0.8307秒

加载时间:0.8444秒

加载时间:0.9014秒

平均速度无压缩:0.80808

压缩平均速度:0.8504

希望有人帮助!

干杯,
$ b $bCiarán

HI I know about
ob_start( ''ob_gzhandler'' );
But I''m looking for something that removes all line breaks and extra
whitespace in the html before sending it to the visitor''s browser. Is
this possible?

Cheers,
Ciarán

解决方案

Hi,

This comment has an example of stripping whitespace:

http://ru.php.net/manual/en/function.ob-start.php#71953

On Mar 22, 9:48 pm, "Ciaran" <cronok...@hotmail.comwrote:

HI I know about
ob_start( ''ob_gzhandler'' );
But I''m looking for something that removes all line breaks and extra
whitespace in the html before sending it to the visitor''s browser. Is
this possible?

Cheers,
Ciarán



Hmm, yeah looks good. Thanks a lot Peter.

Does anyone know if it''s worth it? I mean is the time spent running
the function less then the time it would take to download the longer
html file? Any thoughts on this?

Cheers,
Ciarán


OK I ran a few tests on my slowest page... Here''s my results:

WITHOUT COMPRESSION FUNCTION:::::::::::
Page Size: 523.97 kb
Load Time: 0.9995 seconds
Load Time: 0.8 seconds
Load Time: 0.8095 seconds
Load Time: 0.7091 seconds
Load Time: 0.7223 seconds

WITH COMPRESSION FUNCTION:::::::::::
Page Size: 494.77 kb
Load Time: 0.8448 seconds
Load Time: 0.8307 seconds
Load Time: 0.8307 seconds
Load Time: 0.8444 seconds
Load Time: 0.9014 seconds

AVERAGE SPEED WITHOUT COMPRESSION: 0.80808
AVERAGE SPEED WITH COMPRESSION: 0.8504

Hope that helps someone!
Cheers,
Ciarán


这篇关于使用php压缩html输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆