小编典典
CSS和Javascript
考虑以下链接以最小化Javascript / CSS文件:
HTML
告诉Apache使用GZip交付HTML-这通常将响应大小减少了约70%。(如果使用Apache,则配置gzip的模块取决于您的版本:Apache
1.3使用mod_gzip,而Apache 2.x使用mod_deflate。)
接受编码:gzip,放气
内容编码:gzip
使用以下代码段通过ob_start帮助缓冲区从HTML删除空格:
function sanitize_output($buffer) {
$search = array(
'/\>[^\S ]+/s', // strip whitespaces after tags, except space
'/[^\S ]+\
'/(\s)+/s', // shorten multiple whitespace sequences
'//' // Remove HTML comments
);
$replace = array(
'>',
'
'\\1',
''
);
$buffer = preg_replace($search, $replace, $buffer);
return $buffer;
}
ob_start("sanitize_output");
?>
2020-05-10