Hi !!..
Another tip to improve. :)
You disable the solution above.
(Only for those who have set up)
$xoopsTpl->load_filter('outputfilter.trimwhitespace');
The trick that I propose is more interesting. ;)
And easy to implement.
It allows compressed code directly in the files in place.
Therefore, the compression is done "before" saving the file cached.
The previous solution was performing compression (Minify Html) when displaying pages.
The solution that I propose to you now, it will compress the code, when creating the file it is cached.
/xoops_data/caches/smarty_cache/your-file-cache.html.php
/xoops_data/caches/smarty_compile/your-file-cache.html.php
How?
it is very simple.
in folder : /class/smarty/
Open file : Smarty_Compiler.class.php
Add in line
424Just before this code: $compiled_content = $template_header . $compiled_content;
return true;
}
Add this code: /*************** HACK iLUC Minify HTML / COMPRESS CODE *******************/
$compiled_content = trim(preg_replace('/((?)n)[s]+/m', '1', $compiled_content));
$compiled_content = preg_replace('##s', '', $compiled_content);
$compiled_content = preg_replace("/(rn|n|r)/", "", $compiled_content);
$compiled_content = str_replace(CHR(13).CHR(10),"",$compiled_content);
$compiled_content = preg_replace("/(nn|nnn)/", "", $compiled_content);
$compiled_content = preg_replace("#>(s+)<#s", "><", $compiled_content);
At the end, you must have the following: [...]
if ($this->_init_smarty_vars) {
$template_header .= "require_once(SMARTY_CORE_DIR . 'core.assign_smarty_interface.php');nsmarty_core_assign_smarty_interface(null, $this); ?>n";
$this->_init_smarty_vars = false;
}
/*************** HACK iLUC Minify HTML / COMPRESS CODE *******************/
$compiled_content = trim(preg_replace('/((?)n)[s]+/m', '1', $compiled_content));
$compiled_content = preg_replace('##s', '', $compiled_content);
$compiled_content = preg_replace("/(rn|n|r)/", "", $compiled_content);
$compiled_content = str_replace(CHR(13).CHR(10),"",$compiled_content);
$compiled_content = preg_replace("/(nn|nnn)/", "", $compiled_content);
$compiled_content = preg_replace("#>(s+)<#s", "><", $compiled_content);
$compiled_content = $template_header . $compiled_content;
return true;
}
[...]
Your compress code is Active !! and even better!