Date: Tue, 24 Jan 2012 20:44:51 -0800
Subject: Improved minifier to restore contents, remove even more spaces,
and process CSS with its own rules.
---
system/core/Output.php | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/system/core/Output.php b/system/core/Output.php
index 55a505c34..bb39a7f31 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -582,12 +582,45 @@ class CI_Output {
switch ($type)
{
case 'html':
+
+ // Keep track of tags as they were before processing.
+ // We'll want to return them to this state later.
+ preg_match_all('{}msU',$output,$pres_clean);
+
+ // Keep track of tags as they were before processing.
+ // We'll want to return them to this state later.
+ preg_match_all('{}msU',$output,$style_clean);
+ // Run }msU',$output,$style_clean);
-
- // Run }msU',$output,$style_clean);
foreach ($style_clean[0] as $s)
{
- $output = str_replace($s, $this->minify($s,'css'), $output);
+ $output = str_replace($s, $this->minify($s,'text/css'), $output);
}
// Replace multiple spaces with a single space.
@@ -614,7 +614,7 @@ class CI_Output {
break;
- case 'css':
+ case 'text/css':
// Remove spaces around curly brackets, colons, and semi-colons
$output = preg_replace('!\s*(:|;|}|{)\s*!','$1',$output);
--
cgit v1.2.3-24-g4f1b
From 5de117549f69465a1ce0f2e128428d9adadd8a6d Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)"
Date: Tue, 24 Jan 2012 22:08:36 -0800
Subject: Strips out HTML comments.
---
system/core/Output.php | 3 +++
1 file changed, 3 insertions(+)
diff --git a/system/core/Output.php b/system/core/Output.php
index 47c00acd8..8992fc1f1 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -600,6 +600,9 @@ class CI_Output {
// Replace multiple spaces with a single space.
$output = preg_replace('!\s{2,}!',"\n",$output);
+ // Remove comments (non-MSIE conditionals)
+ $output = preg_replace('{\s*\s*}msU','',$output);
+
// Remove spaces around block-level elements.
$output = preg_replace('{\s*(?(html|head|title|meta|script|link|style|body|h[1-6]|div|p|br).*>)\s*}', '$1', $output);
--
cgit v1.2.3-24-g4f1b
From f59ec6fe4fab3bd5ff71d920e13f983454a9fb65 Mon Sep 17 00:00:00 2001
From: "Thor (atiredmachine)"
Date: Tue, 24 Jan 2012 22:19:14 -0800
Subject: Logs 'debug' message that shows how much % was shaved off.
---
system/core/Output.php | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/system/core/Output.php b/system/core/Output.php
index 8992fc1f1..c95f551ec 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -582,7 +582,9 @@ class CI_Output {
switch ($type)
{
case 'text/html':
-
+
+ $size_before = strlen($output);
+
// Keep track of and