![]() |
Compress Forum Templates (Speed up your Forums & Save Bandwidth)
Compress Forum Templates & Phrases Speed up your Forums & Save Bandwidth Description: Hi, this is a pretty simple hack that involves compressing the 'compiled' version of your templates, this way it only compresses the part thats to be shown on the forum and not the actual template data you edit. Background: Got the idea from Zero Tolerance in buro9's thread: https://vborg.vbsupport.ru/showthread.php?t=69787 The above hack compresses the page at parse time, while it provides some speed enhancement, on large pages you can actually "negate" the point of using the hack in the first place, because of the overhead in compression. Thus, the creation of this hack is to provide similiar functionality, but done in the adminCP; and without the overhead of constant compression. Info: No Queries. Only query is used when compressing your templates, the rest of the time its just pulling the templates straight out of the database like normal. Updates: Version 2.8 - Added Strip Whitespace from Start of JS Line by buro9 Version 2.7 - Option to strip HTML Comments from Compressed Output Version 2.6 - Removed Phrase Compression altogether, Too Iffy Version 2.5 - Removed the ASCII \n removal, emails should work now. Version 2.4 - Had to add editor_jsoptions_size to the Bad Templates array, it also was causing a font selection error. Version 2.3 - Added Phrase compression support, should help further increase page compression. Version 2.2 - Slightly Recoded Template compression for faster results. Version 2.1 - Added php_include templates to bad templates, will not compress these. Version 2.0 - Recoded Script, added support for certain templates to not compress Version 1.9 - Re-Added support for InLine Styles. Version 1.8 - Removed support for InLine Styles, all Style data is left with Linebreaks. Version 1.7 - Removed support for InLine Javascript, all JavaScript is left with Linebreaks. Version 1.6 - Fixed Tab problem, tabs are replaced with a single space Version 1.5 - Removed a part of the SQL. Version 1.4 - TOTALLY Remade, Works perfect now; Ultimate Compression Version 1.3 - Adjusted Again Version 1.2 - Adjusted Stripping regex Version 1.1 - Added Uncompress Support Version 1.0 - Release Install: Step 1. [ Open admincp/template.php ] Step 2. [ Go to about line: 1278, or just look for $_REQUEST['do'] == 'edit' ] Step 3. [ Above Step 2, add the below code ] PHP Code:
Step 5. [ look for ] PHP Code:
PHP Code:
1. Install 2. In the admincp left navigation, select "Compress Templates". 3. Repeat Step 2 after each modification of your Templates whenever you decide to change something. 4. If you want to uncompress all Templates, select "Uncompress Templates" 5. IF Any Templates Come Out Weird, add the template Name to the Bad Templates Array and Re-Run the Compress Templates. |
So if I'm understanding you right..
The part the page loads has the spaces stripped, but when you edit the template in the admincp, it has all the spaces there for ease of navigating? Would it be possible or would it help even more to strip out the html commenting? |
I tryed this out and it gave me some javascript errors on showthread and the portal page. This might be just applying to my board however.
Luckly I downloaded a backup of my templates before I tryed it out. |
Quote:
----------- Ps. Re-Editing a template, resaves the normal version of it, so really you would only need to re-save a template that was causing the js errors. That or fix the JS. |
Quote:
This script just modifies the output copy, that way the editing copy is still easy to edit. |
Update:
Added support to uncompress all templates. |
Update:
Adjust the whitespace regex, might prevent javascript errors.. |
I installed this hack but when I compress the templates my dropdown menu does not work. When I click it the page just shoots to the top of the screen?
Laters |
Quote:
I redid the regex somewhat again, and it works; just not compressing as much as it used to; im gonna keep trying some different methods. |
This weekend I'm refreshing my test site with the live site files, then I'll give this a healthy test run :)
|
Quote:
Although after the latest code change, I'm pretty sure it fixed the problem with JS. |
Quote:
Negates the one I was working on for Zero Tolerence ;) (I'm stuck with a fried hard-drive so it's in limbo... so I really appreciate this being picked up by someone else :)) I'm actually going to install this myself... even though I wrote the compress hack :D |
I've sent an update from my hack to let people know of yours.
I think it's a very valuable addition to any vBulletin admins arsenal of essential hacks :) |
Quote:
Since this is editing the actual parsed templates, one one regex needs to be written, not 2 like we are using now.. The problem lies within the JS tags, need to make one that removes whitespace AND tabs,newlines from every tag outside of <!-- // --> and <!-- -->, anything within those, retains its linebreaks and whitespace... |
Quote:
Can this be used alongside your hack? |
Quote:
|
Quote:
|
Isnt this adding a query?
|
It only runs the query when you compress the templates in the admincp. That step.
It doesn't add an additional query to any pages. |
Does this work with other hacks that you know of?
|
I haven't tossed this onto my test site yet, but there isn't any hacks that would contradict this.
He's using add below/above rather then replace code, which is rockin and it's a total new function. Nothing for it to clash with. |
This hack is truly amazing, I really can feel, see and notice the difference!
Two thumbs up! Highly recommendable! |
Added to my forum and it seems to be loading quicker here. My load average jumped up but it seems to be coming down.. probably just eaccelerator updating the cache.
|
Hrm,
I think i can notice a slight difference with this installed, seem's to be working so far. Good job |
Im almost done with an update guys, Im writing code to take care of the removing of whitespace.
|
UPDATE:
Finished the new version, it works great. Checks template line for line, removing any and all whitespace, tabs etc.. checked the result in IE/Firefox with NO Errors. Script is made to go "around" the javascript, so its left in its natural state except the tabs. |
This is brilliant! My forums are so much faster, thanks :D
|
Ok, I have a problem, I use this in my phpinclude_start:
Code:
switch(intval(time() / 2) % 4) |
Quote:
PHP Code:
Code:
<!-- logo --> |
Nope, still doesnt work :(
|
it just displays my alt tag :(
|
Quote:
Contact with Blamz, fixed problem. Notice; Everyone, even if you have installed this hack. REINSTALL it with the latest code, it drastically changes some stuff that would cause errors otherwise.. |
New version installed, just one quickie before I do anything;
Should I uncompress before applying the new way to compress? Edit: One more thing, the reputation images gets very seperated after this hack :-/ |
Quote:
In other words, everytime you select Compress Templates its compressing them freshly. |
Quote:
|
Quote:
Try uncompress/compress, if that doesn't work, paste the html code of posts where this is affected, if I see what the html looks like I may can help you. Almost post a screenshot. |
Works aok for me, not sure if I see much of a difference performance wise
|
Quote:
If you use this in addition to gzip compression you will save roughly 50-60% in total bandwidth per page. |
Quote:
Uncompressing, and then compressing again removed the whitespace between the reputation images :D |
This latest code does not work for me in IE, the one before worked ok. What Im getting now is my dropdown menues work ok but when I click the New Posts link nothing happens?
Owe well. |
All times are GMT. The time now is 03:20 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|