2025年02月15日 建站教程
wordoress如何利用Gzip实现js和css进行压缩,下面web建站小编给大家详细介绍一下具体方法!
1、压缩的文件需要注意:
如果要压缩style.css,需要把名称改成style.css.php,引入:
<link rel='stylesheet' type='text/css' media='screen' href='/style.css.php'/>
2、在style.css.php上面新增以下语句
<?php if(extension_loaded(‘zlib’)) {ob_start(‘ob_gzhandler’);}header(“Content-type: text/css”); ?>
3、在最后加上下面代码:
<?php if(extension_loaded(‘zlib’)) {ob_end_flush();} ?>
本文链接:http://so.lmcjl.com/news/23212/