vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Graveyard (https://vborg.vbsupport.ru/forumdisplay.php?f=224)
-   -   Board Optimization - Page Output Compression - Whitespace stripper. (https://vborg.vbsupport.ru/showthread.php?t=69787)

blueuniverse 11-28-2004 05:15 AM

Quote:

Originally Posted by Paul M
Which other one ?

That is basically the final version that people came up with - it uses the more agressive stripping except for the listed scripts, where it uses the 'lite' version.

The full one at the beginning. What I want really is just a lite version, which strips all the tags but won't affect the formatting in the post.

buro9 11-28-2004 07:47 AM

Quote:

Originally Posted by blueuniverse
The full one at the beginning. What I want really is just a lite version, which strips all the tags but won't affect the formatting in the post.

Originally I offered the hack in two parts... a full aggressive version and a lite version.

The hack was then modified by some users to run both parts according to which php file was being run... and this is a good idea so I changed the hack to reflect these modifications.

If you want just a lite version then the code is still there, just take out the bits that the aggressive version and the switch would need.

What this means is that where I now have this in the hack:
PHP Code:

// HACK : START : COMPRESS
$thisscriptis = array(
    
'editpost',
    
'register',
    
'newreply',
    
'newthread',
    
'sendmessage',
    
'private',
);

if (!
in_array(THIS_SCRIPT$thisscriptis)) {
    
$patterns = array('/\>\s+\</''/^\s*/m');
    
$replace = array('> <''');
    
$vartext preg_replace($patterns$replace$vartext);
} else {
    
$vartext preg_replace('/\>\s+\</''> <'$vartext);
}
// HACK : END : COMPRESS 

You only need this to have a lite version:
PHP Code:

// HACK : START : COMPRESS
$vartext preg_replace('/\>\s+\</''> <'$vartext);
// HACK : END : COMPRESS 

Note that we still recognised one scenario where this would be annoying... and that is when your forum is one where people are likely to post HTML or XML within their posts within PRE tags... as the formatting of that would also be changed.

So in that scenario the recommendation was that you don't run this hack... as it is designed to remove whitespace and that means that it re-formats HTML, XHTML, XML style text.

Anyhow... hope that helps.

blueuniverse 11-28-2004 08:03 AM

Ok then. Thats pretty simple. Anyway, thanks for the hack, hopefully it should speed stuff up significantly. :)

blueuniverse 11-28-2004 03:31 PM

Also, is the aggressive version a better bet for those who don't offer html in the posts. Are there any other disadvantages?

buro9 11-28-2004 09:58 PM

Quote:

Originally Posted by blueuniverse
Also, is the aggressive version a better bet for those who don't offer html in the posts. Are there any other disadvantages?

The difference is this:

The 'lite' version only collapses whitespace between HTML tags.

The 'aggressive' version collapses all whitespace, even where it does not occur between HTML tags.

There is no performance impact when using one over the other.

The difference is the output... the aggressive can remove more... but if you have people posting things like guitar tablature then the whitespace needed for formatting that is changed and it ruins it.

Because the lite version only touches the space between HTML, the lite version wouldn't affect that.

It just depends how much you want to remove :)

newtsys 01-14-2005 07:34 PM

very good I installed it on my 3.0.5 and it definately sped the forum up!

Bad Bunny 02-07-2005 06:09 PM

Thanks for the work. It does it's job, and even my small forum was sped up significantly. :)

Erwin 02-07-2005 08:55 PM

I still use this on 3.0.6 - works well. :)

Lord Brar 02-08-2005 01:57 AM

wow! I can't belive the pageloading times now!!! Thanks a lot for the hack mate!

Eternal2u 02-23-2005 12:44 PM

when you do this mod you ++++ the code tags..all the text inside the code is also on one line..which for some people isn't that big of a deal...for me it is..installed..then quickly uninstalled..

BigCheeze 02-25-2005 06:23 PM

Installed and seems to be working nicely on a "patched" 3.0.6

Stryker[X] 02-28-2005 10:54 PM

Help! I installed it and got an error so I removed the code and now I get this on any page of the forums!

Parse error: parse error, unexpected $, expecting ',' or ';' in /homepages/15/d110888008/htdocs/thegamernation.com/forums/includes/functions.php on line 3734

Gunshot 03-01-2005 12:03 AM

Very nice boost in speed on all pages

thank you

moppenet 03-05-2005 12:34 AM

Is this fixed in 3.0.7?

Mosh 03-28-2005 04:35 AM

Quote:

Originally Posted by moppenet
Is this fixed in 3.0.7?

If you are asking if this hack works with 3.0.7, then the answer is yes it works, I have it installed myself both the aggressive and lite versions combined.

If that is not what you are asking, can you please clarify what you are referring to please.

Thanks,

jd :)

JulianD 04-08-2005 03:38 AM

Installed this hack with no modification at all.

Just add this to your phpinclude_end template:

PHP Code:

$thisscriptis = array(
    
'editpost',
    
'register',
    
'newreply',
    
'newthread',
    
'sendmessage',
    
'private',
);
if (!
in_array(THIS_SCRIPT$thisscriptis)) {
    
$patterns = array('/\>\s+\</''/^\s*/m');
    
$replace = array('> <''');
    
$output preg_replace($patterns$replace$output);
} else {
    
$output preg_replace('/\>\s+\</''> <'$output);



Zero Tolerance 04-08-2005 01:20 PM

To save execution time, wouldn't it be better to do this upon "saving" a template to the database? That way it has already been stripped, and it doesn't need to be done upon page load, i know it won't make much of a performance difference, but if i page uses a LOT of HTML and a LOT of templates combined, it might take longer to load by a little bit.

Also seen as how vBulletin saves the template to the database in 2 forms, you just strip the whitespaces and such for the actual template shown on the site, while the default remains the same for when you edit it via the ACP?

Nice addition none the less, just thought that implementation could make it better :)

- Zero Tolerance

buro9 04-08-2005 01:31 PM

Interesting.

Where's the second stored instance?

The datastore stores styles but not templates. The template table has too columns that look good contenders... is the first 'template' the one I should modify?

Hmmm... I should also do bbcodeparse too shouldn't I, to get the content.

Certainly possible, but not as simple to install and support as this one ;) Which is a large part of how I now like to write stuff ;)

Zero Tolerance 04-08-2005 02:07 PM

In the table "template", there are 2 fields, one is: "template", and the other is "template_un". The first one is the one displayed on the forums, and already parsed (phrase tags, if conditionals, etc..), and the second one is the one un-parsed, for when editing via the ACP (it meant that vB didn't have to waste execution time to unparse the template upon editing/search/find & replace). My idea was that you modified the ACP style control file, so after saving a template, the data that gets saved to "template" has white spaces stripped.

- Zero Tolerance

sross 04-14-2005 08:37 AM

So let me get this right. for the lite version I place in the includes file:

Quote:

// HACK : START : COMPRESS
$vartext = preg_replace('/\>\s+\</', '> <', $vartext);
// HACK : END : COMPRESS
Questions.. does this alter all my files or is it only changing whats output? I mean if I open my files via ftp will they be all compressed?
-If something goes wrong can I back out of this by just removing the code? What happened to that guy above who tried to back out and is toast? I'd like to install this but am scared it will screw something up beyond repair? thanks!

buro9 04-14-2005 08:46 AM

Quote:

Originally Posted by sross
So let me get this right. for the lite version I place in the includes file:



Questions.. does this alter all my files or is it only changing whats output? I mean if I open my files via ftp will they be all compressed?
-If something goes wrong can I back out of this by just removing the code? What happened to that guy above who tried to back out and is toast? I'd like to install this but am scared it will screw something up beyond repair? thanks!

To answer if that would give you the lite version... yes that would.

It compresses the output given to any web request... not your source files... so your files via FTP are untouched, this only strips whitespace from what is returned to a web request.

If you don't like this, then delete the lines you added.

Not sure which guy couldn't back out and is toast... there's just nothing that can really go wrong, it doesn't touch your source files, your templates, nothing.

The only scenario that might put you off is this: If your forum has people posting stuff within <pre> blocks (think the [code] bbcode) then where that depends on whitespace for formatting the whitespace is removed and formatting can be mucked up as a result.

So if you're a technical forum where people post chunks of HTML in code tags, then you might think that this hack is not for you.

However in all other cases this hack has no ill effect on your forum and does speed up rendering of the page on most browsers (I haven't viewed it in Opera, Safari or Lynx so I have no idea what it does for them, but IE and Firefox both seem to render faster with this hack in place), which is the point of it :)

buro9 04-14-2005 08:49 AM

Quote:

Originally Posted by Stryker[X]
Help! I installed it and got an error so I removed the code and now I get this on any page of the forums!

Parse error: parse error, unexpected $, expecting ',' or ';' in /homepages/15/d110888008/htdocs/thegamernation.com/forums/includes/functions.php on line 3734

Right, just seen this... I have no idea what you have done... but will place a fair guess that you deleted too much when you removed the code or left a stray character in place.

You only added the stuff between and including the // HACK lines right? And then you deleted just those lines to uninstall right? If so then that process cannot cause what you have posted alone... you must have either left a $ in place or deleted too much from your code.

Worst case scenario: download vb from the members part of vb.com and compare the original vb file with your one and restore the bit that you accidentally deleted or left in.

sross 04-14-2005 10:45 AM

I applied the lite version on one of my more busy forums 3.0.7 and WOWOWOWOW HUGE difference!, THANKS!!

wolfyman 04-15-2005 05:05 PM

The Wolfyman likes :D

Fallback 06-14-2005 08:04 PM

Can/should this hack be used WITH the "Compress Forum Templates & Phrases" hack?

Do the hacks conflict?

buro9 06-14-2005 08:21 PM

Quote:

Originally Posted by Fallback
Can/should this hack be used WITH the "Compress Forum Templates & Phrases" hack?

Do the hacks conflict?

They can work together quite fine... though you'd not gain much from doing so.

The hacks do not conflict.

I recommend Trigunflames hack as my hack will perform the whitespace stripping every page load, which attributes to server load. Trigunflames is a manual step, you click to compress your templates in your AdminCP... once done though, you don't need to do it again until the next time you edit a template.

Zia 01-12-2006 03:40 PM

Quote:

Originally Posted by buro9
Hehe... I just noticed you said 3.0.0. Well, the hack version does say 3.0.3 ;)

It works anyway... just place the hack BEFORE the $pageendtime variable is set :)

sounds nice...does it works for vb 3.5.3 ?

buro9 01-14-2006 08:32 PM

Quote:

Originally Posted by Zia
sounds nice...does it works for vb 3.5.3 ?

There's no need. An alternative method almost the same has already been produced:
https://vborg.vbsupport.ru/showthread.php?t=83248

But there is still the far superior one here that Trigunflame produced and that I helped with:
https://vborg.vbsupport.ru/showthread.php?t=79923

That one is easy to get working in 3.5.x (view the end of the thread), and is superior because it only compresses once, rather than on every page request.

dethfire 01-14-2006 08:39 PM

Quote:

Originally Posted by buro9
There's no need. An alternative method almost the same has already been produced:
https://vborg.vbsupport.ru/showthread.php?t=83248

But there is still the far superior one here that Trigunflame produced and that I helped with:
https://vborg.vbsupport.ru/showthread.php?t=79923

That one is easy to get working in 3.5.x (view the end of the thread), and is superior because it only compresses once, rather than on every page request.

anyway to make yours a plugin?

buro9 01-14-2006 08:43 PM

Quote:

Originally Posted by dethfire
anyway to make yours a plugin?

The first of the two links I gave above is precisely that.

The second could possibly be made a plugin, but it's really simple to install and instructions still valid... do you really need one?


All times are GMT. The time now is 02:42 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01472 seconds
  • Memory Usage 1,825KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (12)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (30)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete