Version: 1.1.0, by ShiningArcanine
Developer Last Online: Nov 2023
Version: 3.5.0 Beta 1
Rating:
Released: 06-16-2005
Last Update: 06-16-2005
Installs: 274
Uses Plugins
No support by the author.
This is a port of Logican's Realtime Template Compressor hack from vBulletin 2.2.x to vBulletin 3.5.0 Beta 1. I wrote this by rewriting a version of the original hack, that I wrote for my forums when they ran 3.0.x, so that it would function as a plugin for 3.5.0.
I had originally sent this to Logican for him to release it but he replied granting me permission to release it; hence why I'm releasing this.
Installation is very simple. Just import the plugin via vBulletin's "Download / Upload Plugins" page in the Plugin System in the Admin Control Panel and you're done.
I'll try to correct any bugs that you might find. Let me know if you like this plugin and don't forget to click the install link if you install this.
Update History
Version 1.1.0: The expression was replaced with a more efficient one that increases the compression level from approximately 1-2% to approximately 4-8%.
Version 1.0.0: Initial Release
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
i meant in your templates... you can remove all the spaces but on my templates it removed code it wasnt supposed to when i did that, best way is to download the whole style and then use a find and replace to add a space to all of them
I played around with this a bit
And after talking to my co-admin (who has quite some knownledge of regular expressions) he told me to exclude <script> and other tag blocks is not possible with one RegEx, it would need additional code.
Well, so I started making some code
This I what I currently have, it gave me a "compression" ratio vom ~10% to ~15% in my tests, while leaving user input, [code] posts and JS fully intact (so far )
I added some comments, so you can see what is done where
PHP Code:
global $ascript, $atext, $apre;
// definition of callback functions
function cb_script($matches)
{
global $ascript;
// cut from output, and store away for later re-inclusion, everything between <textarea> and <pre> tags
// (we do not want to touch those blocks as they may contain wanted whitespace)
$output=preg_replace_callback('/<textarea.*?[^\btextarea>\b]*?textarea>/si', "cb_text", $output);
$output=preg_replace_callback('/<pre.*?[^\bpre>\b]*?pre>/si', "cb_pre", $output);
// strip all whitespace at the beginning of every new line (but leave the linebreak intact)
$output=preg_replace('/\r\n(\s*)/', "\n", $output);
// cut from output, and store away for later re-inclusion, everthing between <script> tags
// (we don't want to strip the linebreaks from script code since that would render the scripts non working)
$output=preg_replace_callback('/<script.*?[^\bscript>\b]*?script>/si', "cb_script", $output);
// strip all linebreaks and HTML-Comments from the output
// (since we first strip all linebreaks, even multi-line comments will get striped this way! :-))
$output = str_replace( "\n" , "" , $output );
$output=preg_replace('/<!-- .*? -->/', "", $output);
// and add the compression stats at the very bottom of the page
$output = str_replace('</body>', '<center><span class="smallfont">[<em>page compression: </em>' . $pagenew_kilobyte . 'k/' . $page_kilobyte . 'k (<strong>' . $pagesaved_perc . '%</strong>)]</span></center></body>', $output);
That fixed the advanced mode bug, Hellcat, but hosed tons of other stuff on my forums. For one, the edit/quote buttons at the bottom right of posts were almost overlapped, and the breadcrumbs had no spacing at all.
A step in the right direction though, to be sure.
Screenshot attached of what I'm experiencing. I'd LOVE to get this sorted out - your code, albeit buggy on my particular theme, quadrupled my compression savings.
Hmm.... I think I know what that might cause....
If that's it it would reduce the ratio, but increase compatibility....
[high]* Hellcat starts tweaking
[/high]