Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > vBulletin 2.x > vBulletin 2.x Full Releases
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.00, by Logician Logician is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Version: 2.2.x Rating:
Released: 08-28-2003 Last Update: Never Installs: 78
 
No support by the author.

As you know all vbulletin pages consists of templates and templates consists of HTML (+sometimes javascript) tags.

Nearly in all sites and HTML pages, HTML tags are written in a readable format so that developer can read the source code easily. VB templates abide by this rule too.

However when this "nicely readable" code is called by a visitor, page size unnecessarily increases because of the redundant "spaces" and "line breaks" in the source code which have no useful purpose regarding the page output but is there just for making the source code more readable to the developer.

This hack removes these unnecessary spaces and line breaks from your vbulletin templates AT THE MOMENT they are displayed (in realtime). It does NOT touch your original source code so it is still readable to you when you want to edit it in your admin CP. But it compress the output when they are sent to user's browser.

Removal of these unnecessary characters makes sure:
a) Page output shrinks in all vb pages
b) Thus page loads faster by all visitors
c) You save bandwidth.

Since the removed characters are unnecessary characters, display of your page does NOT change. Please see FAQ below for more info.

This hack is 100% compatible with Teck's Microstat Hack and my Advanced Templates: Dynamic Templates Changing according to different conditions hack and WebTemplates 2.x: VB Integrated Content Management System . It is a very easy to install add (just a few lines in 1 step) yet effective.

I appreciate if you can click INSTALL button, if you use the hack. Thank you. :glasses:

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 08-29-2003, 08:41 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Screenshot:

(Please note: This line will be visible ONLY if you already have your Microstat's hack installed in your server! If you dont have microstats hack, template compressor hack will STILL work and make the same compression, but you will just don't notice this line in your vb pages)
Reply With Quote
  #3  
Old 08-29-2003, 08:42 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

1- How does this hack work?

It removes unnecessary spaces/line break characters from your templates before they are displayed so reduces the size of page output in ALL vb pages. Every space and line break chars between HTML tags takes 1 byte size in your pages so by removing them page sizes become smaller, pages load faster and you save bandwidth.

2- Can you give a live example?
Say any of your vb templates has this content:

PHP Code:
 
 
<table>
    <
tr>
      <
td>
         
Hello
      
</td>
    </
tr>
  </
table
If you count the number of characters in this snippet you would be tricked to think that a html page with this content will take 38 bytes (as each character takes 1 byte). But if you put the code inside a template or .html page and display it, you'll find out that it takes 79 bytes! That 41 extra bytes came from nowhere and eating your bandwidth unnecessarily everytime this page is visited. 32 bytes of these 41 bytes are because of the spaces before < chars which make the HTML tags inlined and thus more readable to the developer. And the rest 7 bytes are lost because each line has an invisible line break characters at the end. You also lost 2 lines for the 2 blank lines at the very beginning and at the very end of the snippet.

However if you wrote the HTML code like this:

PHP Code:
<table><tr><td>Hello</td></tr></table
you would have the exact output but this time your page would take only 38 bytes as there are no more unnecessary spaces or blank lines now.

This is what this hack does. It does NOT change/modify the source code of your templates, but it compress them in realtime whenever they are displayed by a site visitor and make them as if they had written with no spaces and line breaks.

3- But if you remove spaces/line breaks, isn't the display ruined? Are there any downsides of this hack?

The hack does not remove the spaces and line breaks in your own wordings, it just removes them when they are between html tags which are technically useless and unneeded. These spaces are there in the first place so as to make the source code more readable for the developer. But they are actually redundant and eating bandwidth by increasing page size everytime that page is displayed.

I tested the hack extensively in many boards and I can say that it does not bother the display or create any other problems. The only tiny problem I run into is the thread/forum split page links (< [1] 2 3 4 >) getting closer to eachother after hack's installation. No other problems reported.

On the other hands if you have custom javascript codes in your templates, I'm not sure how they can be affected. Default vbulletin javascripts in templates works fine. Also I dont know how the hack is doing with very old or obselete/non-standart browsers. Tested in IE, Netscape and Mozilla and all is fine.

Also if you encounter a display problem in a vb page, first make sure your HTML syntax is correct in your relevant templates that form that page. The hack can be confused in templates where HTML tags are used incorrectly (eg. missing > or < chars etc.). This might happen if you manually customized some templates and used untidy/wrong HTML tags.

4- How much bandwidth is saved with this hack?

It depends. The reduced kilobytes change from page to page because in every page number of removed chars can be different. Also it changes from board to board because how much your templates are cluttered can be different than other boards too, especially if you customized them. If you have many blank lines, inlined design, long spaces between your HTML tags inside your templates, the save will be more. If your templates are already compact, the save will be less.

But to give an estimate I can say that in my tests the hack saved averagely %2 to %5 bandwidth in many boards. If you have Microstats hack installed, you can see how much bandwidth is saved in every vbulletin page while you browse them.

You can read the thread to see users' experience too. Eg. here or here. Also please feel free to share your experience if you have microstats installed and see the gain in your footer.

5- I already have GZIP enabled in my server. How does it go along with this hack? Can I still use this hack?

They can work together and the hack still saves bandwidth even if you have GZIP installed. This is because their compression works differently so having GZIP alone is not sufficent for the compression this hack is doing.

6- I installed the hack but nothing happened?!? I can not see the saved bandwidth line your screenshot displays? Is the hack working? How can I see how much bandwidth is saved?

That line is visible only if you have Teck's Microstats hack installed. If you don't have that hack, template compression hack will still work perfectly and saves bandwidth but you just can not see how much bandwidth you save. In this scenario you won't even notice whether hack is installed or not. To see that line (it is for admin view only), first install Microstats hack and secondly apply the install instructions of this hack which is for the boards that has microstats hack.

7- Do I need Microstats hack to install this hack?
No you don't. This hack will work whether you have Microstats hack or not. But if you have it, you can see how much compression is made by this hack in all vb pages. If you don't have Microstats, then same compression will be performed but you won't know about its stats anymore.


8- What if I go through all templates and remove spaces/new lines manually?

Yes you can and at the end you will have the same bandwidth save in your board that this hack does.
But:
a) It is way a lot of work! There are hundreds of templates you need to edit.
b) It makes your source code hard to read if you later want to change something there as an admin. On the other hand this hack does not touch your source code and it is still readable when you want to edit it, but it just compress it in realtime (only at the moment it is displayed to the user.)

9- After hack is applied, my source code becomes very hard to read! All spaces and new lines are gone!

So isn't this what this hack is suppose to do anyway . Also please note that this is so ONLY IF you check the source code in "view source" link of your browser after page is loaded. Your source is still readable and untouched in your edit template pages which is where you access/update them as an admin. So what matters if users can not get a readable source code? It is better cause it is now harder for them to rip it.

10- I have a display problem about ......... with this hack? Can you fix it?
No I can't because it is not possible. Just uninstall it. As the hack intends to remove such chars, it is not possible to fix the hack if this removal creates an unexpected problem. (Although no such problems have been experienced with this hack yet, I'm mentioning just in case)

11- Can you put a setting to turn the hack's compression ON and OFF in admin CP/options page.

It can be done but I won't do it, my apologies. Such a change will not add a feature that will make the hack work better or more functional but it is just for make up. I prefer to keep hacks as simple as possible so that they can be easily installed by even newbiews. The hack as it is just 1 step and a few lines of change at the moment which is very easy to install for anyone. I don't want to make the installation sophisticated to add a make up change. If someone feels to add this change, he is welcome to share it here with other hack users.

12- Why didnt you code the hack to remove "HTML comment lines" from templates too? You would save more bandwidth.

Right but at the moment hack's core (the line which makes the removals) is 1 line only and to remove HTML comments I needed to add more lines which might slighly increase PHP time of the script. IMO the gain from HTML comment removal is not worth having these lines. Besides you can easily remove such comments manually from your templates via TEMPLATE SEARCH feature in your admin CP as they are not too many.

13- Does the hack add SQL queries?
Nope, it does not.

14- Does the hack work in all vb versions?

Tested in vb 2.3.0. Though should work in all 2.x.x. VB3 hacks are not allowed while VB3 is in beta stage so please do not ask for a VB3 version.
Reply With Quote
  #4  
Old 08-29-2003, 08:53 AM
Brad Brad is offline
 
Join Date: Nov 2001
Posts: 4,765
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Very nice, im going to apply this to vB 3 . Great idea, and good documintation as always.
Reply With Quote
  #5  
Old 08-29-2003, 08:56 AM
assassingod's Avatar
assassingod assassingod is offline
 
Join Date: Jul 2002
Posts: 3,337
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 10:53 AM Anime-loo said this in Post #4
and good documintation as always.
Amen to that!

Cool hack
Reply With Quote
  #6  
Old 08-29-2003, 10:00 AM
MrNase MrNase is offline
 
Join Date: May 2003
Location: Germany
Posts: 670
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

check out webmasterplan.com

test your forums before and after installing it


Before:
Quote:
Anzahl der Elemente auf dieser Seite: 17
Seitengr?sse insgesamt (in Bytes): 881916
Theoretische Ladezeit bei Modem 28.8 kps (in Sek.): 244.98
Theoretische Ladezeit bei ISDN 64 kps (in Sek.): 110.24
Bewertung (nach Schulnoten): 6

After:
Quote:
Anzahl der Elemente auf dieser Seite: 17
Seitengr?sse insgesamt (in Bytes): 845160
Theoretische Ladezeit bei Modem 28.8 kps (in Sek.): 234.77
Theoretische Ladezeit bei ISDN 64 kps (in Sek.): 105.64
Bewertung (nach Schulnoten): 6

Thank you
Reply With Quote
  #7  
Old 08-29-2003, 10:16 AM
lasto lasto is offline
 
Join Date: Jan 2002
Posts: 1,514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

$versionnum=phpversion(); dont have this in my functions.php so can u give me a clue where im to add it as i have microstats already installed so unsure why i dont have that line.
Reply With Quote
  #8  
Old 08-29-2003, 10:31 AM
Logician's Avatar
Logician Logician is offline
 
Join Date: Nov 2001
Location: inside vb code
Posts: 4,449
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Today at 02:16 PM lasto said this in Post #7
$versionnum=phpversion(); dont have this in my functions.php so can u give me a clue where im to add it as i have microstats already installed so unsure why i dont have that line.
If you already have Microstats, you must have this line because it is a part of Microstats code. You can confirm it if you check Microstat's hack's installation document.

Check around lines 500-600 in functions.php.
Reply With Quote
  #9  
Old 08-29-2003, 10:37 AM
lasto lasto is offline
 
Join Date: Jan 2002
Posts: 1,514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

yeah was me bein dumb search never found it but i did

before -

Page generated in 0.12308896 seconds (76.08% PHP - 23.92% MySQL) with 21 queries.
[Debug Mode OFF] [PHP v4.3.2] [GZIP disabled] [Server Load: 0.46 ? 0.46 : 0.39]

After this mini Hack

Page generated in 0.10551906 seconds (73.14% PHP - 26.86% MySQL) with 21 queries.
[Debug Mode OFF] [PHP v4.3.2] [GZIP disabled] [Output: 30.36 Kb. compressed to 28.65 Kb. by saving 1.71 Kb. (5.65%)] [Server Load: 0.73 ? 0.67 : 0.59]

[high]* lasto clicked install[/high]
Reply With Quote
  #10  
Old 08-29-2003, 10:38 AM
lasto lasto is offline
 
Join Date: Jan 2002
Posts: 1,514
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

wow i like this one - ok logician i installed your other hack yesterday and made meself a template in admin cp using web templates now look at savings on this page.

Page generated in 0.09775603 seconds (81.29% PHP - 18.71% MySQL) with 12 queries.
[Debug Mode OFF] [PHP v4.3.2] [GZIP disabled] [Output: 15.22 Kb. compressed to 9.82 Kb. by saving 5.40 Kb. (35.50%)] [Server Load: 0.40 » 0.50 : 0.53]
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:41 PM.


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.05099 seconds
  • Memory Usage 2,325KB
  • 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
  • (2)bbcode_php
  • (4)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
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (10)postbit_onlinestatus
  • (10)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_postinfo_query
  • fetch_postinfo
  • 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