summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThor (atiredmachine) <thor@bandwidthbeta.com>2012-01-25 01:56:01 +0100
committerThor (atiredmachine) <thor@bandwidthbeta.com>2012-01-25 01:56:01 +0100
commit63678a27864fdd6bb0ed89e6940a1d331121072a (patch)
tree81ef3b2a3fbc74f72e6b14c64caefad4be2d51f4
parentb2c077e1e359650b444d5dc73a8fa8b94f469425 (diff)
Rudimentary minifying of output.
-rw-r--r--application/config/config.php13
-rwxr-xr-xsystem/core/Output.php36
2 files changed, 49 insertions, 0 deletions
diff --git a/application/config/config.php b/application/config/config.php
index 17b854b29..3231f1d19 100644
--- a/application/config/config.php
+++ b/application/config/config.php
@@ -357,6 +357,18 @@ $config['compress_output'] = FALSE;
/*
|--------------------------------------------------------------------------
+| Minify
+|--------------------------------------------------------------------------
+|
+| Removes extra characters (usually unnecessary spaces) from your
+| output for faster page load speeds. Makes your outputted HTML source
+| code less readable.
+|
+*/
+$config['minify_output'] = FALSE;
+
+/*
+|--------------------------------------------------------------------------
| Master Time Reference
|--------------------------------------------------------------------------
|
@@ -396,5 +408,6 @@ $config['rewrite_short_tags'] = FALSE;
$config['proxy_ips'] = '';
+
/* End of file config.php */
/* Location: ./application/config/config.php */
diff --git a/system/core/Output.php b/system/core/Output.php
index 1f214a0b3..55a505c34 100755
--- a/system/core/Output.php
+++ b/system/core/Output.php
@@ -323,6 +323,15 @@ class CI_Output {
{
$output =& $this->final_output;
}
+
+ // --------------------------------------------------------------------
+
+ // Is minify requested?
+ if ($CFG->item('minify_output') === TRUE)
+ {
+ $output = $this->minify($output);
+ }
+
// --------------------------------------------------------------------
@@ -558,6 +567,33 @@ class CI_Output {
}
+
+
+ // --------------------------------------------------------------------
+ /**
+ * Reduce excessive size of HTML content.
+ *
+ * @param string
+ * @param string
+ * @return string
+ */
+ public function minify($output,$type='html')
+ {
+ switch ($type)
+ {
+ case 'html':
+
+ // Replaces multiple spaces with a single space.
+ $output = preg_replace('!\s{2,}!',' ',$output);
+
+ // ...
+ break;
+ }
+
+ return $output;
+ }
+
+
}
/* End of file Output.php */