View Full Version : Board Optimization - Page Output Compression - Whitespace stripper.
buro9
09-22-2004, 10:00 PM
No longer supported by the author.
nexialys
09-23-2004, 04:11 PM
this have been done in another hack related to templates compression...
most of the time, it's not good to have such a feature because html is not written well, or is not xhtml relevent...
buro9
09-23-2004, 04:18 PM
this have been done in another hack related to templates compression...
I did search, maybe you could point to where this is.
most of the time, it's not good to have such a feature because html is not written well, or is not xhtml relevent...
The hack doesn't break things, it doesn't affect JavaScript, etc... it merely collapses white space.
As both HTML and XHTML renderers ignore white space the hack can't possibly do anything that the HTML or XHTML wasn't already doing.
I've tested it on my forum and been sure to not upset anything anywhere... I only replace multiple white spaces with a single space... there is no chance a renderering engine will alter what it does because of this.
If I didn't put back 1 white space for the many taken out, then I would agree that I might be affecting the page display or something... as someone might've relied on spacing. However, I leave a single space in there for that reason.
Please show me how my hack does what you imply.
Red Blaze
09-23-2004, 08:14 PM
I'm using 3.0.0, and I had to do something else, and still worked.
You see, I didn't find:
if (DB_QUERIES)
{
But I did find:
$pageendtime = microtime();
I just put:
$patterns = array('/\>\s+\</', '/^\s*/m');
$replace = array('> <', '');
$vartext = preg_replace($patterns, $replace, $vartext);
AFTER what I had to find and it works just as you said. Now my forums are running faster. ^^;;
buro9
09-23-2004, 08:48 PM
I'm using 3.0.0, and I had to do something else, and still worked.
You see, I didn't find:
if (DB_QUERIES)
{
But I did find:
$pageendtime = microtime();
Strange indeed.
I've just checked the default file from Jelsoft for vBulletin 3.0.3 and the code as I've pasted it is on line 1852. So it is there when shipped.
You must've removed it at some point, maybe for another hack?
Well... no worries. If it didn't have the if (DB_QUERIES) block then you would be best to place the hack code BEFORE the $pageendtime variable. Otherwise the stat you get telling you how long the page took to load will not reflect the inclusion of the hack, as the $pageendtime is literally the timestamp of the page as it finishes being generated.
buro9
09-23-2004, 08:49 PM
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 :)
58sniper
09-23-2004, 09:13 PM
That won't work if someone uses the <pre> tag, which utilizes whitespace for formatting.
buro9
09-23-2004, 10:24 PM
That won't work if someone uses the <pre> tag, which utilizes whitespace for formatting.
A fine point... added a 'lite' version to the first post that leaves white space at the beginning of lines alone.
However if you have a tech site in which you paste lots of HTML, etc... and you want to preserve space within that. Then you'd be best not using this hack at all ;)
Ghostsuit
09-24-2004, 01:40 AM
Simple and effective. Oh and anyone that has VB3 MicroStats hack installed will not be able to find
if (DB_QUERIES)
{
$pageendtime = microtime();
so place it before
if (DB_QUERIES)
{
$ms = '';
Thats should do the job.
mrboz
09-25-2004, 10:17 PM
wow - this makes every page load much faster
thanks very much, great hack.
buro9
09-25-2004, 11:47 PM
wow - this makes every page load much faster
thanks very much, great hack.
Your site will be even quicker if you let vBulletin store your CSS as external files. Then they can cache in the browser and you send less with each page request :)
turbidblue
09-26-2004, 12:09 AM
Your site will be even quicker if you let vBulletin store your CSS as external files. Then they can cache in the browser and you send less with each page request :)
how?
* turbidblue is interested ;)
buro9
09-26-2004, 12:31 PM
how?
* turbidblue is interested ;)
Check your AdminCP options:
AdminCP > vBulletin Options > Style & Language Settings > Store CSS Stylesheets as Files? = Yes
Note that vBulletin needs to be able to write the files to the folder:
If you would like to store the CSS stylesheet for each style as a file, you must ensure that you have a directory called 'vbulletin_css' inside the 'clientscript' folder, and that the web server has permission to write and delete files within that directory.
So you will need to create the directory is it doesn't exist, and then CHMOD the directory in question to have permissions something like 755 or 775 depending on how your Apache is configured. You don't want to CHMOD it 777... you never want to do that.
You can usually set permissions via FTP programs or SFTP... but it can always be done from SSH or Telnet :)
buro9
09-26-2004, 12:35 PM
Check your AdminCP options:
AdminCP > vBulletin Options > Style & Language Settings > Store CSS Stylesheets as Files? = Yes
Note that vBulletin needs to be able to write the files to the folder:
So you will need to create the directory is it doesn't exist, and then CHMOD the directory in question to have permissions something like 755 or 775 depending on how your Apache is configured. You don't want to CHMOD it 777... you never want to do that.
You can usually set permissions via FTP programs or SFTP... but it can always be done from SSH or Telnet :)
And yes, I realise that 664 is probably a better chmod... but you know... some servers I've been on are just lovely and hardened and prevent writing withour very specific chmod values... 755 and 775 being the most common two... so I was being lazy in giving execute too as this prevents people bugging me about something unrelated to the hack ;)
Paul M
09-26-2004, 02:58 PM
The full version screws up nicely formatted posts when you edit them, so I have used the "lite" version which doesn't do this.
buro9
09-26-2004, 04:14 PM
The full version screws up nicely formatted posts when you edit them, so I have used the "lite" version which doesn't do this.
Yes, I think I'll switch them around and suggest the lite version for all... and then those who want the aggressive version can opt for that if they wish.
AlexanderT
09-27-2004, 06:29 AM
On average I've been witnessing it strip about 8% of total page bytes from every generated page.
We all GZIP don't we? The benefits of this is that all gaps between HTML become the same pattern, and so they compress better for GZIP'ing.
David, can you show me examples of your findings? I generally don't believe that the compression ratio is that much affected by the mere presence of whitespace. But of course I could be wrong ;)
buro9
09-27-2004, 07:57 AM
David, can you show me examples of your findings? I generally don't believe that the compression ratio is that much affected by the mere presence of whitespace. But of course I could be wrong ;)
Hehe, that was a nice challenge, but one I enjoyed.
To offer a proof I've done the following:
wget my forum index.php both compressed using the now default non-aggressive regexp, and also without this hack applied.
The sizes of the two files:
37,732 bytes = Compressed file
41,348 bytes = Uncompressed file
A 9% reduction in filesize.
I then ran gzip from within SSH, this should be the same as PHP gzip'ing them or a close approximation thereof:
6,748 bytes = Compressed + GZIP
8,102 bytes = Uncompressed + GZIP
A 20% reduction in final filesize.
The additional reduction of the size is higher than merely the white space being stripped and is an indicator that doing this does offer a benefit to GZIP.
So the compressed page (exactly the same HTML but without white space) ends up being 20% lighter with GZIP'ing than the non-compressed page.
Of course, the mileage varies on every page and with each style that you use. I should point out that the above was run against my current forum homepage which is not the default vBulletin style and that I've hacked my page quite a lot. So the filesize of your page and the amount it compresses and the amount it GZIPs are all factors depending on your configuration and the amount of whitespace in a page, etc.
The worst I've seen from this hack is a mere 3% reduction in file size on some of the smaller pages (such as the error messages).
The biggest benefit isn't the saved 1k of traffic... but the speed at which the rendering increases. Whether that is because the file transfered quicker, of the DHTML engine didn't have to work so hard ignoring whitespace, etc... I simply do not know... but it does appear to render faster and that is my prime goal :)
buro9
09-27-2004, 08:23 AM
Of course... all of the above is simply a bigger advert for turning on GZIP than using this hack ;)
If anyone doesn't have GZIP turned on in their vBulletin... I suggest you do that first :)
AlexanderT
09-27-2004, 02:22 PM
Ok, convinced. Thanks ;)
Jolten
09-28-2004, 12:50 AM
Unfortunately, this will also strip white space when editing posts. That's NOT good.
buro9
09-28-2004, 01:33 PM
Unfortunately, this will also strip white space when editing posts. That's NOT good.
This is indeed true.
However the basic non-aggressive one will one strip excess space between ">" and "<".
Unless you have HTML in your posts this shouldn't matter.
Does this impact anything? Such as the WYSIWYG editor? I've been running it for a little while on my site and I haven't noticed any detrimental effects when editing posts.
If you can give a detailed example I'll have a look and see what can be done about it.
My site runs with a history of all edits (an edit log), so I can diff between changes to see how this effects it.
dethfire
09-28-2004, 02:47 PM
this lowered my homepage size by 3kb, it's a quick hack so worth the small effot :)
Jolten
09-28-2004, 03:41 PM
Essentially it strips all returns out of posts when editing. In general, it's not a big issue but for long posts it's a little tiresome to have to go insert returns again. I did have the more aggressive version installed. I'll try the lesser one and see if that helps a little.
Paul M
09-28-2004, 04:04 PM
Essentially it strips all returns out of posts when editing. In general, it's not a big issue but for long posts it's a little tiresome to have to go insert returns again. I did have the more aggressive version installed. I'll try the lesser one and see if that helps a little.The full version screws up nicely formatted posts when you edit them, so I have used the "lite" version which doesn't do this. ... :)
HuangA
09-28-2004, 04:28 PM
This hack have a good concept; but it is not the best way to preserve bandwidth...
For example; if your site is not webmaster oriented, your members will be unlikely to post as much HTML/other contents that needs trimming, thus it wouldn't affect your site as much. If your site is webmaster oriented, you will want to preserve the code the way it is (for demonstration and code representation purpose). The members will have a hard time trying to learn:
<?
if ( !$happy ) {
print $sad_string;
}
?>
if they don't know php and all they see is
<? if (!$happy){print $sad_string;}?>
And that's only a basic example, think what chaos it'd do with stuff like:
if (!$a):$b or die(print($c)) is presented to a newbie?
buro9
09-28-2004, 07:43 PM
Oh absolutely.
But bandwidth preservation wasn't the #1 priority... delivery to the rendering engine and reduction of work for the rendering engine was.
If you have a site that is going to use CODE tags, etc... then use the now defaulted 'lite' version.
For those of you who do not post code, etc in CODE tags, and care not for <pre> tags... then the aggressive version will suit your needs and save a few more spaces.
buro9
09-28-2004, 07:45 PM
And if you want to save bandwidth:
* Turn on GZIP
* Remove images where you consider them excess
* look at removing any redundent tags in the templates... you optimise the HTML ;)
Etc.
Removing a few images will do more than this does... but this will help it display faster ;)
Mickie D
09-29-2004, 10:46 AM
for those having problems with the edit posts and new threads posts, PMS etc etc i have made this little addition that will switch to the light version if you view them pages (i think it works lol)
$thisscriptis = array(
'editpost',
'register',
'newreply',
'newthread',
'sendmessage'
);
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);
}
thanks to mystic for the code fix i forgot to add
i wrote that out really quick so sorry if its not coded proppa but you get the idea ;)
I clicked Install !!!!!!!!!!!!! terrific! :laugh: :banana:
Mystics
10-03-2004, 04:58 PM
(i think it works lol)Better change it to this: $thisscriptis = array(
'editpost',
'register',
'newreply',
'newthread',
'sendmessage'
);
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);
}:)
Mickie D
10-11-2004, 01:00 PM
yeah mystics is right i did change it on my site and forgot to change it on here i will update that post :)
* Mosh clicks install (Mystics version)
But credits to buro9 too, for getting me to read the entire thread through in the 1st place as it is a very interesting way of speeding things up.
JD :)
SaN-DeeP
10-17-2004, 06:44 AM
/me installs.
I can see the difference, page loads faster for me
Thankx for this great 1 line hack
REgards,
Mickie D
10-17-2004, 08:28 AM
* jdsinclair clicks install (Mystics version)
But credits to buro9 too, for getting me to read the entire thread through in the 1st place as it is a very interesting way of speeding things up.
JD :)
dont you mean Mickie D's version ?
never mind i guess me thinking up the whole THIS_SCRIPT idea dont count and i already had the fix on my site i just forgot to update here :(
but as always thanks for mystics pointing it out to everyone else.
last but not least you wll also want to add private into the array so it does not screw up private messages
find
'editpost',
under it add
'private',
Regards
Mickie D
GlitterKill
10-18-2004, 01:19 AM
Very nice! forum pages are noticably snappier.
Can this be implemented on other non VB php pages? How would that be done? I'm sure the rest of my site could benefit from this. :)
*installed*
Makador
10-18-2004, 02:53 PM
Great! Thank you very much.
gwhooooey
10-18-2004, 10:09 PM
I've got https://vborg.vbsupport.ru/showthread.php?t=62173 installed
...which splits up the two bits of line that you say to add the code before... so can you look at this hack and then tell me where i'd put your code. Thanks
dont you mean Mickie D's version ?
never mind i guess me thinking up the whole THIS_SCRIPT idea dont count and i already had the fix on my site i just forgot to update here :(
but as always thanks for mystics pointing it out to everyone else.
last but not least you wll also want to add private into the array so it does not screw up private messages
find
'editpost',
under it add
'private',
Regards
Mickie D
Hehehehe, hey thanked Mystics because it was his exact code I used :)
Thank you also Mickie D, cause I am now going to add the 'private', line to it. :)
JD :)
MickDoneDee
10-19-2004, 12:02 PM
I've got https://vborg.vbsupport.ru/showthread.php?t=62173 installed
...which splits up the two bits of line that you say to add the code before... so can you look at this hack and then tell me where i'd put your code. Thanks
Does this (https://vborg.vbsupport.ru/showpost.php?p=555483) post help?
gwhooooey
10-19-2004, 07:49 PM
Yes it did, thank you
diettalk
10-23-2004, 12:03 PM
I'm having a problem when people try to "preview" a messages.. it takes out the lines between the paragraphs .. on either a new post or edit.
Use this: ;)
https://vborg.vbsupport.ru/showpost.php?p=558462&postcount=31
Just have a look in my Sourcecode http://halloo.de/forum.php
buro9
10-24-2004, 10:33 PM
Thx Mickie D and Mystics for the additions, do you mind if I move them back into the first post?
I didn't realise this was nominated for HoTM and I suppose it's best to tidy up my first post ;)
turkforum
10-27-2004, 03:14 AM
installed and my forum works ( i guess) much faster great hack
https://vborg.vbsupport.ru/showpost.php?p=558462&postcount=31
Oblivion Knight
10-27-2004, 08:25 AM
Simple and effective. Oh and anyone that has VB3 MicroStats hack installed will not be able to find
if (DB_QUERIES)
{
$pageendtime = microtime();
so place it before
if (DB_QUERIES)
{
$ms = '';
Thats should do the job.Actually, this is wrong.. Buro stated to add the code ABOVE this:
$pageendtime = microtime();Otherwise, the page loading time will be inaccurate. ;)
Tradjick
10-29-2004, 04:11 PM
This hack is sooo sweet. It changed my forumhome output from 46.100 bytes to 38.770 bytes which means from 100% to 84% which is a gain of 16% in decreased size. Thanks you!
Gutspiller
10-31-2004, 02:22 AM
So after all the discussion in this thread, does this hack screw up when you edit a post?
What about when you are applying a hack and it has you look for certain code? If you do a search for the code from what somebody gives you to search for, if your spaces aren't right, won't the search turn up zero results because you've removed the spacing?
msimplay
10-31-2004, 08:23 AM
is there a way so formatting where [html] tag doesn't get messed up ?
maybe an if condition ?
Oblivion Knight
10-31-2004, 09:23 AM
If you run a journal system, you may also want to add journal in to the $thisscriptis array.. :)
Amavisca
10-31-2004, 03:57 PM
when i try to put 'journal' in, it game an error
Oblivion Knight
10-31-2004, 04:02 PM
Make sure that the line above has a commar after it..
It should look something like this:
$thisscriptis = array(
'editpost',
'register',
'newreply',
'newthread',
'sendmessage',
'private',
'journal'
);
Amavisca
10-31-2004, 04:09 PM
Thnx for the quick reply ok, yep i forget the comma. I have another question if u can answer: what does this info tell u :
Page generated in 0.53191209 seconds (65.18% PHP - 34.82% MySQL) with 13 queries
DEBUG Mode OFF | GZIP ON (level 1) | 0.41 : 0.40 : 0.37 | No uncached Templates
and btw I just move to a dedicate server but the serverload and memory is very high sometimes, how can i keep it low>?
msimplay
10-31-2004, 05:43 PM
isn't there a way to just exclude the html tag from the white space stripper ?
Oblivion Knight
10-31-2004, 05:50 PM
what does this info tell u :
Page generated in 0.53191209 seconds (65.18% PHP - 34.82% MySQL) with 13 queries
DEBUG Mode OFF | GZIP ON (level 1) | 0.41 : 0.40 : 0.37 | No uncached Templates
and btw I just move to a dedicate server but the serverload and memory is very high sometimes, how can i keep it low>?What page are those stats from, and what hacks do you have installed? The page generation time and server loads are both higher than what I'd deem as normal.
isn't there a way to just exclude the html tag from the white space stripper ?If you use the "lite" version; the php, code and html tags shouldn't be affected.
Deimos
10-31-2004, 05:53 PM
Works ok for me, I installed it.
Definite speed improvement.
Amavisca
10-31-2004, 06:42 PM
What page are those stats from, and what hacks do you have installed? The page generation time and server loads are both higher than what I'd deem as normal.
It is from my forumhome ( which has quite a few icon image and lots forums ) and I did install the Micro Stat hax.
msimplay
10-31-2004, 07:28 PM
If you use the "lite" version; the php, code and html tags shouldn't be affected.
hmm have u tested this coz for me it did change the way it rendered the page
code and php tags are unaffected but html tag goes haywire
^^ sorry
apparently this works with it great
$thisscriptis = array(
'editpost',
'register',
'newreply',
'newthread',
'sendmessage'
);
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);
}
Mickie D
10-31-2004, 07:50 PM
@buro9 feel free to do with it what ever you wish :)
this hack is great most people want to install games and pets (and i do aswell lol) but when they use vb some more and their sites get busier they will be running to these mods.
@amavisca http://turck-mmcache.sourceforge.net/index_old.html <---- the best software for php (and to all other people you wont be able to use this unless you have ssh access or you have a nice host that will install it for ya)
buro9
11-02-2004, 12:41 PM
@buro9 feel free to do with it what ever you wish :)
this hack is great most people want to install games and pets (and i do aswell lol) but when they use vb some more and their sites get busier they will be running to these mods.
@amavisca http://turck-mmcache.sourceforge.net/index_old.html <---- the best software for php (and to all other people you wont be able to use this unless you have ssh access or you have a nice host that will install it for ya)
First post adjusted to use the array version (simpler than explaining what is going on with a 'lite' or 'extreme' version).
Also added credit to those in this thread who have helped others resolve problems and questions from others.
Also modified the instruction to say AFTER a chunk of code, rather than BEFORE. As the old version depended on not having microstats installed... the new version should be clearer for all of those who want to install it... microstats or not.
Gutspiller
11-02-2004, 04:51 PM
So if we use the lite version regular code that is edited during adding a new hack won't be affected and look different?
Is there a big difference between the lite and extreme versions as far as page loading speed is concerned?
Say, if I was interested in the fastest speed, maybe install all the hacks I ever wanted installed on my board and then as the very last hack run the extreme version of this that "compresses" all the code together, so the code looked like sheet, but at least they loaded fast?
buro9
11-02-2004, 06:44 PM
No difference to any hacks... all hacks will run prior to this (except microstats), and it is the final HTML for the whole page that has whitespace stripped.
I couldn't see a difference between the old lite and extreme versions on page rendering... I suspect it's just too small to be noticeable. The only difference between those two versions is how much whitespace is left in the page... you are fine to use the lite one without anything messing up, but some of us like being a little too anal and stripping as much as we safely can even when the difference is arguable... "if it doesn't cost anything, then do it" is my philosophy.
Yup, that last line describes what it does. But I've only this evening updated the hack (see the first post)... so there isn't a seperation between lite and extreme. It runs the and the extreme stuff where it can, and the lite stuff everywhere else.
Erwin
11-03-2004, 03:50 AM
I've installed this and it seems to work well. Good idea.
Natch
11-04-2004, 12:40 AM
^ ^ ^ The ultimate test ;)
I had this modification enhanced. Because I work on calendar :rolleyes:
// ###################### Page Output Compression #######################
$thisscriptis = array(
'editpost',
'register',
'newreply',
'newthread',
'sendmessage',
'calendar',
'faq',
'profile',
'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);
}
// ###################### Page Output Compression #######################
Mijae
11-09-2004, 08:09 PM
Works for me!
I turned gzip to 1, applied this hack, and my forums are loading so fast I cant believe it.
MickDoneDee
11-17-2004, 09:59 PM
*installed* Simple installation and great results.
I already had VB3 MicroStats (https://vborg.vbsupport.ru/showthread.php?s=&threadid=62173) installed so I added the code BEFORE:
$pageendtime = microtime();
Results:
Page generated in 0.13810205 with hack 0.32 : 0.24 : 0.19 index.php
Page generated in 0.13857198 without hack 0.15 : 0.29 : 0.23
Page generated in 0.23258996 with hack 0.23 : 0.23 : 0.18 England forumdisplay
Page generated in 0.23134303 without hack 0.55 : 0.31 : 0.22
Page generated in 0.45348811 with hack 0.08 : 0.19 : 0.17 showthread - The 1981 Ashes series revisited
Page generated in 0.45551610 without hack 0.53 : 0.37 : 0.25 As you can see there's not a lot of difference in the speed that the pages are generated but there is a significant reduction in average server load.
I have a broadband connection and the increased download speed is only marginally apparent. According to Speedar (http://www.rietta.com/freebies/speedar/index.php) my connection speed is approx. 104.2 kilobytes/sec.
I also did a gzip test (http://www.desilva.biz/gzip-test.php) which produced the following result for my homepage:
The webpage is COMPRESSED / GZIPPED!
>> Savings: 80%
Filesize: 55.6KB [11.2KB] html / text only
MickDoneDee
11-18-2004, 10:17 AM
Sorry, I had to uninstall this because I need to use Code tags occasionally to display tables properly and this hack causes tables to display incorrectly. Pity a solution can't be found for this otherwise it is a great hack.
Is there a version that doesn't alter the spaces within Code, PHP and Pre tags?
buro9
11-19-2004, 12:15 PM
Is there a version that doesn't alter the spaces within Code, PHP and Pre tags?
No.
It could theorhetically be done, but the additional overhead in doing so would hurt you in performance.
I'd need to regexp for <pre> and </pre>, chop those out, perform the strip, and put those backin... string concats and chops of that size is far more intensive than simply the current regexp for the strip.
Would people really want a solution that was heavier on the processing?
MickDoneDee
11-19-2004, 12:57 PM
Hi buro9, I can live without the pre tags but I do need to use the code tags to display tables properly. Is that possible? Or does the code tags present the same problems as the pre tags?
buro9
11-19-2004, 01:22 PM
Hi buro9, I can live without the pre tags but I do need to use the code tags to display tables properly. Is that possible? Or does the code tags present the same problems as the pre tags?
Precisely the same problem.
Doable... but then it's more intensive and I personally wouldn't want have added something intensive to every page.
Robert9
11-20-2004, 09:10 AM
yo,yo. Nice idea, but why dont improve the code itself. If i watch the code of templates there is about 30% to save i think. Nobody needs things like
cellpadding="0" if cellpadding=0 do the same; for a lot of other parts it goes the same ...
Natch
11-20-2004, 11:12 AM
yo,yo. Nice idea, but why dont improve the code itself. If i watch the code of templates there is about 30% to save i think. Nobody needs things like
cellpadding="0" if cellpadding=0 do the same; for a lot of other parts it goes the same ...
Not exactly true: cellpadding=0 is not valid, cellpadding='0' and cellpadding="0" are the same, but cellpadding=0 is not...
Example, <img src=image name.jpg alt=an image on my webpage border=0> << very bad...
buro9
11-21-2004, 06:39 AM
Yup, because for it to be XHTML valid, all attributes MUST be quoted regardless of datatype of value (i.e. even if it is a number, or a string without spaces, it still needs quoting).
And of course, feel free to modify all of your code, and then you will see why vBulletin left some pieces of styling and spacing within HTML and not CSS... compatibility for CSS is still shakey for those not using the very latest browsers (still shakey for some that are using the latest browsers).
blueuniverse
11-23-2004, 07:00 PM
Am I missing something, as you've mentioned both lite and extreme versions? I only see one at the beginning of the thread, is this the lite version? I've probably missed something and looked like a fool, lol :p
blueuniverse
11-27-2004, 06:55 PM
Anybody??? Am I doomed to suffer from slow loading times and bloated bandwidth usage forever. Noooooooo
Paul M
11-27-2004, 07:01 PM
Anybody??? Am I doomed to suffer from slow loading times and bloated bandwidth usage forever. Noooooooo
Use the version in post 65 (https://vborg.vbsupport.ru/showpost.php?p=569476). :)
blueuniverse
11-27-2004, 07:21 PM
what exactly does that do though in comparison to the other one?
Paul M
11-27-2004, 11:26 PM
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.
NightWalk8r
11-27-2004, 11:42 PM
Kick a$$!!!!!!
great hack =)
blueuniverse
11-28-2004, 05:15 AM
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
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:
// 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:
// 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
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?
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:
$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:
// 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
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
']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
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.
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
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
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
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?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.