Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 3.5 > vBulletin 3.5 Add-ons
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Realtime Template Compressor: Reduces page sizes, loads pages faster, saves bandwidth Details »»
Realtime Template Compressor: Reduces page sizes, loads pages faster, saves bandwidth
Version: 1.1.0, by ShiningArcanine ShiningArcanine is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

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.

Comments
  #242  
Old 01-23-2006, 03:17 PM
Guest210212002
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by ryuji
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
So are you saying that if I have:

Code:
<!--This is my comment-->
That I need to change them to:

Code:
<!-- This is my comment -->
Like that?
Reply With Quote
  #243  
Old 01-23-2006, 04:51 PM
ryuji ryuji is offline
 
Join Date: Jan 2006
Posts: 35
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thats all i had to do.. and it solved issues with the scripts
Reply With Quote
  #244  
Old 01-25-2006, 12:30 AM
Hellcat Hellcat is offline
 
Join Date: May 2003
Location: Germany
Posts: 560
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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;

  
$i count($ascript) + 1;
  
$h md5($matches[0]);
  
$ascript[$i][0] = $matches[0];
  
$ascript[$i][1] = $h;

  return 
$h;
}

function 
cb_text($matches)
{
  global 
$atext;

  
$i count($atext) + 1;
  
$h md5($matches[0]);
  
$atext[$i][0] = $matches[0];
  
$atext[$i][1] = $h;

  return 
$h;
}

function 
cb_pre($matches)
{
  global 
$apre;

  
$i count($apre) + 1;
  
$h md5($matches[0]);
  
$apre[$i][0] = $matches[0];
  
$apre[$i][1] = $h;

  return 
$h;
}


// init some variables/arrays
$page_byte=strlen($output);
$ascript = array();
$atext   = array();
$apre    = array();

// 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);

// re-insert everything we saved before
foreach ( $ascript as $block)
{
  
$output str_replace$block[1] , $block[0] , $output );
}
foreach ( 
$atext as $block)
{
  
$output str_replace$block[1] , $block[0] , $output );
}
foreach ( 
$apre as $block)
{
  
$output str_replace$block[1] , $block[0] , $output );
}

// calculate some nice looking numbers :-)
$pagenew_byte=strlen($output);
$page_kilobyte=number_format(($page_byte/1024),2);
$pagenew_kilobyte=number_format(($pagenew_byte/1024),2);
$pagesaved_byte=$page_byte-$pagenew_byte;
$pagesaved_kilobyte=number_format((($pagesaved_byte)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byte)/$page_byte),2);

// 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); 
Reply With Quote
  #245  
Old 01-25-2006, 01:00 AM
Guest210212002
Guest
 
Posts: n/a
Default

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.
Reply With Quote
  #246  
Old 01-25-2006, 01:02 AM
Guest210212002
Guest
 
Posts: n/a
Default

For reference, a screeny of my forums using my existing code, which only strips comments.
Reply With Quote
  #247  
Old 01-25-2006, 01:49 AM
Hellcat Hellcat is offline
 
Join Date: May 2003
Location: Germany
Posts: 560
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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]

[EDIT]
OK, try this:

In my above posted code, find theese two lines:
Code:
$output = str_replace( "\n" , "" , $output ); 
$output=preg_replace('/<!-- .*? -->/', "", $output);
and replace them by those:
Code:
$output = str_replace( "\n" , " " , $output );
$output = preg_replace('/<!--[^\{]*?-->/', "", $output);
Like I already said, this drops the ratio a bit again, but should raise compatibility.
At least I could confirm this in my last tests....

[high]* Hellcat waits for feedback now [/high]
Reply With Quote
  #248  
Old 01-25-2006, 02:29 AM
The Chief's Avatar
The Chief The Chief is offline
 
Join Date: Aug 2005
Location: Montreal
Posts: 1,037
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

does this work with vB Drupal?
Reply With Quote
  #249  
Old 01-25-2006, 02:32 AM
Hellcat Hellcat is offline
 
Join Date: May 2003
Location: Germany
Posts: 560
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by gamebgs
does this work with vB Drupal?
Hmm, can't test that since I don't have that installed.
There's only one way to find out

But it should, yes....
Reply With Quote
  #250  
Old 01-25-2006, 02:36 AM
The Chief's Avatar
The Chief The Chief is offline
 
Join Date: Aug 2005
Location: Montreal
Posts: 1,037
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Hellcat
Hmm, can't test that since I don't have that installed.
There's only one way to find out

But it should, yes....
I'll try that right now

is it supposed to take all the lines away from the source?
Reply With Quote
  #251  
Old 01-25-2006, 02:39 AM
The Chief's Avatar
The Chief The Chief is offline
 
Join Date: Aug 2005
Location: Montreal
Posts: 1,037
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

and the result is: Nope it doesn't work with vb drupal...

works fine for my forums though so installed...

/me clicks install
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:59 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04889 seconds
  • Memory Usage 2,341KB
  • Queries Executed 25 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (4)bbcode_code
  • (1)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (8)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete