/* - * 压缩css文件
- * by bbs.it-home.org
- /*
- header('Content-type: text/css');
- ob_start("compress");
- function compress($buffer) {
- /* remove comments */
- $buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
- /* remove tabs, spaces, newlines, etc. */
- $buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
- return $buffer;
- }
/* 加载要压缩的css文件 */ - include('master.css');
- include('typography.css');
- include('grid.css');
- include('print.css');
- include('handheld.css');
ob_end_flush();
相比这前介绍的 压缩多个CSS与JS文件的php代码 ,这个相对简单一些,适合作为入门参考。 |