PDA

View Full Version : Realtime Template Compressor: Reduces page sizes, loads pages faster, saves bandwidth


Pages : [1] 2

ShiningArcanine
17 Jun 2005, 00:06
This is a port of Logican's Realtime Template Compressor hack (http://www.vbulletin.org/forum/showthread.php?t=56589) 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

womensden
17 Jun 2005, 00:57
Forgetting something?

Robert Basil
17 Jun 2005, 01:09
Yup, looks like the xml file might help. ;)

Martin
17 Jun 2005, 02:17
Yup, looks like the xml file might help. ;)

Mebbe he's practicing for April Fool's Day?;)

fraghappy
17 Jun 2005, 02:52
I'll be interested to see how effective this is after he gets around to giving us the xml file. ;)

Martin
17 Jun 2005, 03:51
I'll be interested to see how effective this is after he gets around to giving us the xml file. ;)
It's there. It's just been Real Time Compressed so tightly that it's invisible to the naked eye as a demonstration of the awesome compression capability he's bringing us.

Andreas
17 Jun 2005, 03:57
It's there. It's just been Real Time Compressed so tightly that it's invisible to the naked eye as a demonstration of the awesome compression capability he's bringing us.
LOL. Anyway, the idea of removing whitespaces is good - saves 5-10% Bandwidth (even with GZip), and the pages are being rendered faster.

Marco van Herwaarden
17 Jun 2005, 05:52
Did you contact the original author for permission to port his hack?

kall
17 Jun 2005, 06:50
Did you contact the original author for permission to port his hack?


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.


That would tend to suggest so.

jpt62089
17 Jun 2005, 08:03
wow I love this hack! its.... its.... just....... AMAZING! lol :p

so when do we get our hands on the XML? vB 10? hehe :P

Marco van Herwaarden
17 Jun 2005, 08:28
Oops

/me makes a mental note to read better before replying

ultranerds
17 Jun 2005, 12:47
wow I love this hack! its.... its.... just....... AMAZING! lol :p

so when do we get our hands on the XML? vB 10? hehe :P
Maybe he's sleeping <G> (only posted it earlier today ;)).

Cheers

Andy

ShiningArcanine
17 Jun 2005, 19:06
Forgetting something?
Sorry guys, I could have sworn I attached this. I guess I clicked the wrong submit button. ^_^;;

Anyway, it is attached now. It uses the same perl expression Logician's original hack uses and much of the code is the same. I simply made it work with vBulletin 3.5.0 Beta 1. I'm thinking of writing a new expression for more aggressive compression but my experience with expressions is limited so that'll have to wait until I have some freetime on my hands.

womensden
17 Jun 2005, 19:13
*Installing now*

Thanks. I didn't think you did it on purpose. ;)

ShiningArcanine
17 Jun 2005, 19:23
*Installing now*

Thanks. I didn't think you did it on purpose. ;)
I didn't think you did. :)

Guys, I'm still playing with this but if you open the xml file, find:

/(>)(s*)(\r\n)*(s*)(<)/
Replace it with:

/(>)(\s*)(\r\n)*(\s*)(<)/
And then upload that file instead, the compression soars from 1-2% to 8-10%. I'm still playing with the expression through so you might want to wait until I finish playing with it and release version 1.1.0.

womensden
17 Jun 2005, 19:28
That messed up my tables.

ShiningArcanine
17 Jun 2005, 19:41
That messed up my tables.
Did you edit the XML file and then upload it or did you edit the plugin from the Plugin Manager? There is a problem in vBulletin 3.5.0 Beta 1 when it comes to storing expressions. They seem to get parsed somewhere along the line; hence why I said to edit the xml file.

womensden
17 Jun 2005, 19:45
oh, ok. I'll try that.

womensden
17 Jun 2005, 19:47
That worked! Thanks

mholtum
17 Jun 2005, 20:13
[Output: 36.08 Kb. compressed to 35.71 Kb. by saving 0.37 Kb. (1.03%)]

That is all I am getting. But if I edit the file, the forums get hosed.

Now I am getting:
[Output: 36.08 Kb. compressed to 29.16 Kb. by saving 6.92 Kb. (19.19%)]

womensden
17 Jun 2005, 20:30
I just noticed that in the "new posts" page, the topic titles are crammed against the "go to first new post" icon. There is no space in between. It's fine everywhere else though.

ShiningArcanine
17 Jun 2005, 21:32
That alternate expression was experimental, which is why I said that I was still playing with it. Here is the new one I'm playing with:

/(?(?=\r\n)\s)/

It doesn't compress as well but it doesn't seem to remove any necessary whitespaces so it is a strong candidate for the expression I'm putting in 1.1.0 (as I'm not happy with the current level of compression).

ShiningArcanine
17 Jun 2005, 22:10
It seems that I made writing expressions more complicated than it needed to be. ^_^;;

I wrote something entirely new that I think will be much more efficient so I've released version 1.1.0.

Andreas
17 Jun 2005, 22:15
Your current regex kills whitespaces that are there intentionally.
And you could achieve higher compression if you remove HTML comments.
However, this might cause problems with JavaScript then.

ShiningArcanine
17 Jun 2005, 22:39
KirbyDE, aren't all of the whitespaces there intentionally? The regex in 1.0.0 was Logician's original regex but it didn't compress things well enough and my attempts at an advanced regex compressed things so well that it killed whitespaces that are necessary for the presentation so I wrote a simpler regex that strips the whitespaces at the beginning of each line.

It doesn't have any effect on how you view the page unless you're viewing the XHTML. If you were viewing the XHTML, you would not have any level of template compression enabled on your forums.

I have this installed on my forums if you want to check it out:

http://www.pokemonfanuniverse.com/forums/

By the way, thanks for the tip regarding the comments. I was considering stripping them in a new version but I didn't realize that stripping them might affect javascript. Looking at the syntax Jelsoft used I could probably strip them either by ensuring they're on a single line or by also requring the whitespace found after "<!--" in comments but not in the javascript (from what I can see).

Edit: Also, if anyone is interested in why vBulletin strips slashes from the plugin upon submit/edit, they'll want to check out this bug report at vBulletin.com:

http://www.vbulletin.com/forum/bugs35.php?do=view&bugid=184

It should be fixed in vBulletin 3.5.0 Beta 2 from what I can gather.

Andreas
17 Jun 2005, 22:53
What about that

The following line has 4 spaces at the beginning
Test

ShiningArcanine
17 Jun 2005, 23:22
What about that

The following line has 4 spaces at the beginning
Test


I'm not aware of any stock code in vBulletin written like that and to be honest, that is supposed to use &nbsp; rather than standard whitespaces. Not to mention modern browsers display one whitespace instead of several consecutive whitespaces in HTML web pages even if there are several consecutive whitespaces.

Andreas
18 Jun 2005, 00:13
This is the stock [code] Tag :)
It generates <pre>-Tags, which should preserve whitespaces - but you strip them out.

ShiningArcanine
18 Jun 2005, 00:36
This is the stock [code] Tag :)
It generates <pre>-Tags, which should preserve whitespaces - but you strip them out.
That changes things. Are you proposing a better way of doing it that won't strip those whitespaces or are you leaving it up to me?

By the way, shouldn't Logician's orignal regex also have stripped out those whitespaces?

ja3
18 Jun 2005, 08:47
I use
$output=preg_replace ('/(\s*)\r\n(\s*)/', "", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);

and get about 15% compression, don't know why you still need the \r\n? :)

mholtum
18 Jun 2005, 08:48
[Output: 38.53 Kb. compressed to 31.02 Kb. by saving 7.51 Kb. (19.50%)] is what I am getting from the code he posted later in the thread
:)

nexialys
18 Jun 2005, 14:16
i find strange that this technique was released earlyer for 3.0, and now reproduced it, but in no way Jelsoft thought of adding any of the template compression techniques released here yet...

am i wrong, or all the tests made by Jelsoft are proving that these systems are useless ?! they tend to release modifications that work perfectly, so i suppose that all these things are not... i hope to find something better than the actual but for now, none here have it... (ok, i have something myself, but i'm not releasing any work)

Chris M
18 Jun 2005, 14:47
Very nice hack idea - So far no odd looking tables or anything, and I'm getting about 5% compression :)

Satan

Martin
18 Jun 2005, 23:44
Installed using ja3's code and showing arounf 18-19% compression

womensden
19 Jun 2005, 00:32
I get a lot better compression with ja3's code as well.

womensden
19 Jun 2005, 00:54
I get a lot better compression with ja3's code as well.

Wow, I just had to change it back because it killed my banner.

Martin
19 Jun 2005, 00:57
I noticed a problem. both seem to break line breaks in posts

this

becomes

thisbecomes or this becomes

It was nice while it lasted

ShiningArcanine
19 Jun 2005, 06:03
Martin, would you give me specific instructions on how to reproduce that because I can't seem to reproduce it on my own?

Martin
19 Jun 2005, 07:55
It might be interfence with another another plugin. I didn't test everything.

I just uploaded through the plugin manager. I edited the xml file to add the other compression code and uploaded it seperately.

Martin
19 Jun 2005, 08:05
I just reuploaded and tested again and it does the same thing.

Just in case you were wondering, PHP 4.3.11 MySQL 4.0.21

Martin
19 Jun 2005, 08:07
I think what it's doing is killing the space in the XML compliant line break, breaking it

<br />

becomes <br/>

ja3
19 Jun 2005, 08:22
Hmm strange. It doesnt happen here.

Martin
19 Jun 2005, 08:27
Hmm strange. It doesnt happen here.
It might well be the interaction with another plugin, though the only one i have that affects the postbit is the Buddy/Ignore one.

As long as it affects Quick Edit, I wouldn't use it anywhere except my test board, anyway.

Xplorer4x4
19 Jun 2005, 12:19
Will this work for 3.0.7? I dont see the "Plugin System" in the Admin Control Panel.

Thanks.

womensden
19 Jun 2005, 14:58
Will this work for 3.0.7? I dont see the "Plugin System" in the Admin Control Panel.

Thanks.

3.0.7 doesn't have the plugin system.

Dep
19 Jun 2005, 15:04
i use what ja3 said i get better compression with that


$output=preg_replace ('/<!-- .*? -->/',"",$output);

ja3
19 Jun 2005, 19:28
I found a little error in my code, fixing this asap :)

ShiningArcanine
20 Jun 2005, 22:32
It might well be the interaction with another plugin, though the only one i have that affects the postbit is the Buddy/Ignore one.

As long as it affects Quick Edit, I wouldn't use it anywhere except my test board, anyway.
Martin, would you be able to provide me with copies of the page in question's XHTML source one without the plugin and one with?

Xplorer4x4
21 Jun 2005, 20:36
3.0.7 doesn't have the plugin system.

Is there anyway I can install it anyways? Through my hosting datbase perhaps?

Martin
21 Jun 2005, 23:25
ok, 2 days now, no changes to your code and it seems to be working as advertised. Musta been one of those strange, flukey things.

ShiningArcanine
22 Jun 2005, 04:41
Is there anyway I can install it anyways? Through my hosting datbase perhaps?

I didn ask for permission to release a version for 3.0.x but try copying and pasting the PHP code from the XML file into the phpinclude_end template. ;)

ok, 2 days now, no changes to your code and it seems to be working as advertised. Musta been one of those strange, flukey things.

Probably.

Marco van Herwaarden
22 Jun 2005, 06:52
Could this hack please be uploaded as a zip-file.

Thank you.

merk
22 Jun 2005, 07:52
Has anyone tested how many microseconds it actually takes to do this "compression"?

Interesting idea, but wouldnt it be better to strip the whitespace from templates as they are retrieved, not from the final page output? (meaning post data doesnt have whitespace stripped..)

Xplorer4x4
23 Jun 2005, 23:10
I didn ask for permission to release a version for 3.0.x but try copying and pasting the PHP code from the XML file into the phpinclude_end template. ;)

:) Once i realized not to put any of the < > codes in there, it worked just fine. [Output: 59.22 Kb. compressed to 56.71 Kb. by saving 2.51 Kb. (4.24%)]

Thank you very very much. This is a great mod and EVERYONE should have this installed!

Cole2026
01 Jul 2005, 03:35
:) Once i realized not to put any of the < > codes in there, it worked just fine. [Output: 59.22 Kb. compressed to 56.71 Kb. by saving 2.51 Kb. (4.24%)]

Thank you very very much. This is a great mod and EVERYONE should have this installed!
This corrupts the javascript in the WYSIWYG editor, it renders it useless. :(

MentaL
01 Jul 2005, 03:59
work on b3?

Chris M
01 Jul 2005, 12:30
Does for me :)

Satan

MentaL
01 Jul 2005, 16:05
Installed and featured on www.ragezone.com

shiva
16 Jul 2005, 10:48
anyone know why I am getting the same compression message at the top of my page, just under the logo, and at the bottom of the page at the end of the footer?

pepel13
27 Jul 2005, 02:48
anyone know why I am getting the same compression message at the top of my page, just under the logo, and at the bottom of the page at the end of the footer?

Same thing for me

Is it possible to remove that ??

FleaBag
28 Jul 2005, 04:00
Glad to have this for 3.5. Seems to be working well! :)

safiel
30 Jul 2005, 23:38
anyone know why I am getting the same compression message at the top of my page, just under the logo, and at the bottom of the page at the end of the footer?

This code is placing its compression stats output after your HTML </body> tag. If it is happening twice that means you have two </body> tags, which you shouldn't.

p.s. This is also throws off my tables.

WonderWorm
11 Aug 2005, 12:01
Currently having problems with this plugin for RC2. When I use the advanced edit I lose all formatting for the standard editor. Here is some screenshots to show what I mean. It shows up fine in the quick edit but once I go advanced it loses all the breaks.

http://www.emufanatics.com/quickedit.jpg

http://www.emufanatics.com/advanced.jpg

At first I thought this was being caused by RC2 but after turning off some plugins I narrowed it down to this one. Any help would be appreciated. :)

jugo
11 Aug 2005, 14:56
Is it because the Comment tags are being replced??

If so, Why not use .js scripts and include them instead of putting Java code into the templates.

Just a thought.

Boofo
11 Aug 2005, 15:25
What is the actual code that seems to be working best for everyone?

Cyricx
11 Aug 2005, 16:06
Odd, I'm running it on RC2 and I am having no issues with advanced or normal edit or quick reply.

If you leave all the others on and turn this one off does it still do it?

It sounds like you've got a conflict between this plugin and another.

Brandon Sheley
17 Aug 2005, 09:23
this worked great, first try.
i'm wondering do the plugins work as well with custom skins :-/ i'll have to do some searching :p

thx for the plugin
*clicks install*

diettalk
14 Sep 2005, 08:59
This is happening to me as well with RC3. Is there a way to ignore posting pages or anything between textarea codes?

Currently having problems with this plugin for RC2. When I use the advanced edit I lose all formatting for the standard editor. Here is some screenshots to show what I mean. It shows up fine in the quick edit but once I go advanced it loses all the breaks.

http://www.emufanatics.com/quickedit.jpg

http://www.emufanatics.com/advanced.jpg

At first I thought this was being caused by RC2 but after turning off some plugins I narrowed it down to this one. Any help would be appreciated. :)

BamaStangGuy
14 Sep 2005, 16:55
Confirmed here as well

paulius
18 Sep 2005, 05:43
This works great for me!

As a little note... I found a way to remove the statistics message at the footer of each page by removing the following lines of code in the plugin:

$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);

Cheers and great plugin! I hope that you improve it to make it even more powerful!

jribz
25 Sep 2005, 18:24
I use
$output=preg_replace ('/(\s*)\r\n(\s*)/', "", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);

and get about 15% compression, don't know why you still need the \r\n? :)ja3, I noticed a bit later in this thread you detected an error in your code, but I didn't see you place a fix for it. If I use both lines you have here I get an error on the page with certain dimensions and directories (like the misc image directory not being defined. But if I just use the second line I get no errors and about 10 - 15% compression. Was there a fix for the first line?

bloodwrath
28 Sep 2005, 04:43
works great for me
my pages load so fast i didnt notice they changed
thanks....

SHANE-D-PAIN
28 Sep 2005, 18:42
Cool Hack

Did not think i would have noticed much of a difference but i do and that rocks my socks off or something along those lines....


*Clicks install*

Noonster
30 Sep 2005, 12:37
Currently having problems with this plugin for RC2. When I use the advanced edit I lose all formatting for the standard editor. Here is some screenshots to show what I mean. It shows up fine in the quick edit but once I go advanced it loses all the breaks.

http://www.emufanatics.com/quickedit.jpg

http://www.emufanatics.com/advanced.jpg

At first I thought this was being caused by RC2 but after turning off some plugins I narrowed it down to this one. Any help would be appreciated. :)

I am getting the same Problem with the Gold release :(

Anyone know how to fix the problem??
- I have turned the plugin off for now!

Cheers
Darren

Bulent Tekcan
02 Oct 2005, 09:39
Yes same problem here,I'm already disable it...

jugo
03 Oct 2005, 18:08
finally installed this. I only get an average of 2K per load Savings, but like my wife always says, a penny here and a penny there is a whole lotta dollars down the road.

BTW: Works fine do far on GOLD!!!

kaniksu
03 Oct 2005, 18:53
Just installed, everything looks good... I just loaded a thead:

[Output: 168.10 Kb. compressed to 142.74 Kb. by saving 25.37 Kb. (15.09%)]

Fenriz
05 Oct 2005, 01:45
If I don't want any text information about compression, what should I delete from the xml-file?

jribz
05 Oct 2005, 08:51
If I don't want any text information about compression, what should I delete from the xml-file?That is answered in this post here: http://www.vbulletin.org/forum/showpost.php?p=775446&postcount=70

Fenriz
05 Oct 2005, 12:08
This works great for me!

As a little note... I found a way to remove the statistics message at the footer of each page by removing the following lines of code in the plugin:
$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);

Cheers and great plugin! I hope that you improve it to make it even more powerful!

I think that you also can remove
$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 leave only $page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);

Yorixz
05 Oct 2005, 15:48
Thanks a lot; up to 9% is still 18gb on 200gb monthly traffic ;)

richard4339
06 Oct 2005, 21:22
I didn't like the wording at the bottom, so I modified it to:

52.24 Kb. compressed to 49.95 Kb. eliminating 2.29 Kb. of data. (4.39% compression)

I know thats not technically a correct statement, but I find it to be more readable. Also, thanks, I like this.

Note: I'm getting 4.39% compression. Must be my intensive forums.

Funchiestz
07 Oct 2005, 21:36
I didn't like the wording at the bottom, so I modified it to:

52.24 Kb. compressed to 49.95 Kb. eliminating 2.29 Kb. of data. (4.39% compression)

I know thats not technically a correct statement, but I find it to be more readable. Also, thanks, I like this.

Note: I'm getting 4.39% compression. Must be my intensive forums.

Ehm.. dunt know when i try to active my plugin, i can not press quick reply

i use 3.5 GOLD, can somebody help me?

smokering
08 Oct 2005, 03:50
smokering clicks install and heads off to plug it in plug it in

Neal-UK
08 Oct 2005, 09:55
smokering clicks install and heads off to plug it in plug it in

appears to be working on vb 3.5 gold

vibe
09 Oct 2005, 08:22
works
thanks

michaelbenson
09 Oct 2005, 11:01
Fantastic i have added the modification in right now, and there certainly seems to be a noticable difference in the load times of especially the forumhome page.

Allan
09 Oct 2005, 11:05
work with vB 3.5 gold ?

piXelatedEmpire
09 Oct 2005, 11:18
I think that you also can remove
$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 leave only $page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
Has this been confirmed to work? I only ask as the poster said they 'think' you can remove the listed variables...

hotrod1
10 Oct 2005, 03:32
Great hack, thanks!!!

PennylessZ28
10 Oct 2005, 05:20
I just wanted to say I've been using this and it's a great hack.

I'm seeing Output compression saving 3.2% to 15.57%

Excellent work.

:Judge:
10 Oct 2005, 05:52
Well so far so good, I am not getting 20% or even 10% but it seems a little better. Thank You

piXelatedEmpire
10 Oct 2005, 10:32
I think that you also can remove
$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 leave only $page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
tested this plugin after removing said variables and code, and still seems to function well

Julie
11 Oct 2005, 15:47
Works for me, thanks! :)

Andreas
11 Oct 2005, 17:25
This Hack causes a Division by Zero PHP Error if a totally blank page is being output (due to missing Template or wrong action for example).
Fixed Code attached.

dutchbb
11 Oct 2005, 18:45
This looks really usefull knowing that we need to cut down on bandwidth!!
Thanks again ShiningArcanine, KirbyDE and others for working on this.

Does anyone know how (or where) to add the if conditional to show the stats on pages only to admins?

monstergamer
11 Oct 2005, 18:51
thanks kirby for the update

Emil
11 Oct 2005, 22:33
This Hack causes a Division by Zero PHP Error if a totally blank page is being output (due to missing Template or wrong action for example).
Fixed Code attached.
Thanks! A little question though. I've never installed a plugin before, only products. So what do I choose in the "Hook Location
This specifies the location within the vBulletin code of the hook that will fire this plugin function." option field?

dethfire
12 Oct 2005, 16:36
Paragraph breaks in text are not showing up
when that text is nested within [ quote ] tags.

I also noticed that when I previewed a post containing other tags (in this case, I had [ size] tags), the paragraph break/space just before the tags disappeared. It doesn't do it if you don't preview the post. So, what happens is that the text shows up okay in the preview, but the space is gone from your actual reply, so when you click on "submit," you don't get the same thing that showed up in preview.

dutchbb
12 Oct 2005, 18:36
Does anyone know how (or where) to add the if conditional to show the stats on pages only to admins?
anyone?

Julie
12 Oct 2005, 19:15
This looks really usefull knowing that we need to cut down on bandwidth!!
Thanks again ShiningArcanine, KirbyDE and others for working on this.

Does anyone know how (or where) to add the if conditional to show the stats on pages only to admins?

I couldn't find where the code bit itself was at the moment, but:

<if condition="($bbuserinfo['usergroupid'] == 6)">
<p>Code here for compressor</p>
<else />
<p>Something else perhaps?</p>
</if>

If 6 is your admin group...

Julie
12 Oct 2005, 19:18
Thanks! A little question though. I've never installed a plugin before, only products. So what do I choose in the "Hook Location
This specifies the location within the vBulletin code of the hook that will fire this plugin function." option field?

Hey,

In your AdminCP, just find Plugin System and then Download / Upload Plugins. And just upload the files there, and it does all the work for ya! :)

Emil
12 Oct 2005, 21:11
Hey,

In your AdminCP, just find Plugin System and then Download / Upload Plugins. And just upload the files there, and it does all the work for ya! :)
:nervous: ahh thank you!

Emil
12 Oct 2005, 22:58
It always says "saving 0.00 Kb. (0.00%)" for me. Do I do something wrong or is there just nothing to save on? lol

dutchbb
14 Oct 2005, 14:24
I couldn't find where the code bit itself was at the moment, but:

<if condition="($bbuserinfo['usergroupid'] == 6)">
<p>Code here for compressor</p>
<else />
<p>Something else perhaps?</p>
</if>

If 6 is your admin group...
Thanks, already tried that with no luck. The code or variable isn't in the templates but in the plugin, if I add the conditional there, it has no effect :(

glorify
17 Oct 2005, 22:54
Advanced Thread Previews get all the paragraphs stripped if you edit a thread. Quick AJAX edits keep the paragraphs. Fix?

dethfire
18 Oct 2005, 00:53
Advanced Thread Previews get all the paragraphs stripped if you edit a thread. Quick AJAX edits keep the paragraphs. Fix?

Yeah I mentioned this problem earlier.

glorify
22 Oct 2005, 02:29
Anyone with a fix on this or should I uninstall?

Samira
26 Oct 2005, 01:34
Had to uninstall until the editor issue is fixed.

glorify
26 Oct 2005, 01:48
Me too. :(

FleaBag
28 Oct 2005, 01:04
I actually reported this as a 3.5 Beta bug oops heh... I have uninstalled until a fix comes along also. :)

PET
09 Nov 2005, 09:01
so it's not safe to install ?

steven s
09 Nov 2005, 11:42
You can use it but multiple paragraph returns are stripped.
The post will still be thre, just the formatting changes.
Most messages you won't notice anything.

I've disabled it because people are unable to format some messages clearly without using multiple paragraph returns. It's not a big deal but the I have had users complain.

TJFweb
09 Nov 2005, 12:22
I haven't been having any problems with paragraph stripping. Then again, everyone uses the AJAX editing function. I heard problems only occur with advanced editing, etc.

Anyway, no problems so far here (and I've used it for over 2 weeks on a very active board).

On average it saves about 3%. A tiny amount but nevertheless an optimization.

cbr929rrerion
09 Nov 2005, 12:33
sounds like it has alot of bugs.. let us know when the Final Release is ready...

steven s
20 Nov 2005, 00:03
On average it saves about 3%. A tiny amount but nevertheless an optimization. Not worth the complaints I get though. I hope there is eventually an update.

TJFweb
20 Nov 2005, 02:56
Not worth the complaints I get though. I hope there is eventually an update.

What are people's main compaints about this hack? The problem with paragraph returns?

I use it on a medium sized 3.5.1 board (which is also heavily modded) and I honestly haven't found any bugs or problems with it.

steven s
20 Nov 2005, 03:07
What are people's main compaints about this hack? The problem with paragraph returns?Yes. I know it's minor. One of my boards don't get a lot of traffic but when a few people complain I can't justify it.

aSeEr
21 Nov 2005, 05:27
works fine on 3.5.1 forum .. no bugs or complains :)

Unexplained.tv
21 Nov 2005, 06:07
I would only use this if/when there is a new version out for the latest Vbulletin. I used it before and it worked like it should, I would just like to see an updated version before I allow this to be running on my site again.

dethfire
21 Nov 2005, 06:36
works fine on 3.5.1 forum .. no bugs or complains :)

actually there is a bug that hasn't been fixed, try editing a post, the compressor seems to eliminate the line breaks, so long posts with paragraphs all get lumped together

mrahul
21 Nov 2005, 17:55
is this safe to use or it still contains bugs ??

dethfire
21 Nov 2005, 18:06
is this safe to use or it still contains bugs ??

it's safe, but the known bug is annoying sometimes

Dead End Society
21 Nov 2005, 18:09
I could not use this on my forum either, lots of my users edit posts in the advanced mode to post artwork and pictures. Once it's fixed I will install though, so I'll keep an eye out.

mrahul
22 Nov 2005, 16:42
it's safe, but the known bug is annoying sometimes

can some one fix it out ? I have more than 10k members they use mostly advanced mode.

derekivey
23 Nov 2005, 23:12
Great Hack, I can definitely put this to use.

Thanks!

Bounce
24 Nov 2005, 00:09
Installed thanks :nervous:

Chadi
24 Nov 2005, 00:26
Anyway to remove the actual statistic "quiried in xxx" line?

richard4339
24 Nov 2005, 06:22
If you're referring to the printout at the bottom of the page, simply comment out the code that prints that with

<!-- Text here -->

Forgive my extremely generic answer, it has just been a while since I changed that code.

donBLACK
24 Nov 2005, 08:39
Installs

Chadi
24 Nov 2005, 13:57
Anyone else have a better answer?

lexx27
26 Nov 2005, 01:15
I would only use this if/when there is a new version out for the latest Vbulletin. I used it before and it worked like it should, I would just like to see an updated version before I allow this to be running on my site again.
Mee too. I dont want to risk it

SuperFly
26 Nov 2005, 01:17
It works fine, no errors here

Running on vb 3.5.1

Detomah
26 Nov 2005, 10:55
I love this script, it works fine and is saving me a quite a bit of loading time and bandwidth...

The issue with it killing line beaks in advanced editor is a real downer though, I hope someone will be able to come up with a solution for this, it's doing my users heads in at the moment, making it a bit of a 50-50 whether I keep it installed or not at the moment.

Chadi
28 Nov 2005, 05:14
Anyway to remove the actual statistic "quiried in xxx" line?

Anyone? :)

Chadi
04 Dec 2005, 04:38
6 days now no answer :)

can someone please help? Thank you

AWI
09 Dec 2005, 08:53
Installed, not sure what the effect was on the board. How do you find out the compression rates and such?

steven s
09 Dec 2005, 13:51
Installed, not sure what the effect was on the board. How do you find out the compression rates and such?Look at the bottom of the footer. Also note if you use multiple paragraph returns when using advanced reply, those will be removed.

Edit: It also removed additional spaces.
There should have been five spaces between [ ].

bashy
09 Dec 2005, 21:14
Hi peeps...

I am getting....

[Output: 46.51 Kb. compressed to 43.53 Kb. by saving 2.98 Kb. (6.41%)]

No problems found as yet, Using VB 3.5.2

Thanks alot

Bashy

*Bashy clicks install*

AWI
10 Dec 2005, 06:55
Look at the bottom of the footer. Also note if you use multiple paragraph returns when using advanced reply, those will be removed.

Edit: It also removed additional spaces.
There should have been five spaces between [ ].

Aaah I see it, kinda blends in. Thanks

Daracon
10 Dec 2005, 10:18
works great for me with 3.5.2, *installed*

Rickie3
10 Dec 2005, 11:08
works great *installed*
this is what i'm getting
[Output: 110.04 Kb. compressed to 104.85 Kb. by saving 5.20 Kb. (4.72%)]

tippen
10 Dec 2005, 21:47
THIS is amazing! My dial-up users are ever-so-happy!! I want to thank everyone who had any involvement in the development of this!

[Output: 27.15 Kb. compressed to 25.93 Kb. by saving 1.22 Kb. (4.49%)]

bonjurkes
11 Dec 2005, 01:10
[Output: 198.77 Kb. compressed to 189.96 Kb. by saving 8.81 Kb. (4.43%)]

its working great

Installed ;)

Stephen3
11 Dec 2005, 07:10
so it's work on 3.5.2?

Brandon Sheley
11 Dec 2005, 08:55
so it's work on 3.5.2?

did u read any of the post above this one ?

yes, it works on 3.5.2 :rolleyes:
at least i can assume,, it works fine for me i have 3.5.1 with the 3.5.2 patch

Zilvia
11 Dec 2005, 18:59
Installed and Uninstalled on 3.5.2

Wont use until the advanced edit spacing is fixed.

Great idea however!

Chadi
12 Dec 2005, 03:08
Anyway to remove the actual statistic "quiried in xxx" line?

I asked this 3 weeks ago and until now about 3 or 4 times. No one has answered.

Anyone care to answer?

steven s
12 Dec 2005, 03:18
I asked this 3 weeks ago and until now about 3 or 4 times. No one has answered.

Anyone care to answer?
I'm no longer using it but Plugin system -->Plugin manager
Hook Location : global_complete
Realtime Template Compressor

//Logician Hack:
$page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);

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

$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);
//Logician Hack:
Maybe try commenting the last line out?

Chadi
12 Dec 2005, 04:29
Thank you. That works :)

MissKalunji
13 Dec 2005, 06:20
[Output: 75.28 Kb. compressed to 72.12 Kb. by saving 3.16 Kb. (4.20%)]


what can i do to make the output lower? i hav eno idea why its so big

Dollah
13 Dec 2005, 17:49
yeah this should be good

Heo13
14 Dec 2005, 08:32
[Output: 84.84 Kb. compressed to 80.26 Kb. by saving 4.58 Kb. (5.39%)]

Seem good, but i want more compression :)

dethfire
14 Dec 2005, 17:31
paragraph break bug still exists

Moparx
14 Dec 2005, 19:01
paragraph break bug still exists

of course it does. the plugin hasn't been updated since june..

Mudvayne
14 Dec 2005, 20:05
me clicked install :D

BiReL41r
16 Dec 2005, 21:57
Does anybody know a percentage of the faster loading times on pages?

dreamer81
18 Dec 2005, 10:04
only get about 5% so im gonna wait for something heavier...

Alviker
18 Dec 2005, 21:10
Run in 3.5.1? ^^

Atte. Alviker

steven s
18 Dec 2005, 21:52
Run in 3.5.1? ^^

Atte. Alviker
No reason why it wouldn't.

kau
19 Dec 2005, 02:29
After installing is that it?

Is there a way to see stats on anything or how do I know it's working? If it's uploaded it's working? Should I be able to see it's installed anywhere?

MissKalunji
19 Dec 2005, 03:48
After installing is that it?

Is there a way to see stats on anything or how do I know it's working? If it's uploaded it's working? Should I be able to see it's installed anywhere?


go into your msg board at the bottom you will see at the bottom

Zia
19 Dec 2005, 06:27
yeap..this is really too kool hacks..

im still looking for something more to save/speedup vb?

Thnks

Yorixz
23 Dec 2005, 07:58
I'm still hoping someone will come up with a way to remove that stats, it's messing up my skin :(

MissKalunji
23 Dec 2005, 08:03
I'm still hoping someone will come up with a way to remove that stats, it's messing up my skin :(

http://www.vbulletin.org/forum/showpost.php?p=846646&postcount=149 ?

wtrk
01 Jan 2006, 23:50
this works pretty good. ive used it for a month, it saved 8gb of bandwidth over the previous months usage. nov. was 56gb, dec. was 48gb. of bandwidth.

Danny Diamond
05 Jan 2006, 03:41
I noticed a huge difference. Great plug.

Submerge
05 Jan 2006, 05:43
*Installed

Works great on 3.5.3!

Gripemaster
05 Jan 2006, 05:50
*Clicks install*

My pages are zinging now...even on DSL they are noticeably faster. I'll have a friend do a dialup test tomorrow and get his report. Thanks!!!

mbader71
05 Jan 2006, 07:20
thanks alot,

this is a great hack

firstrebel
06 Jan 2006, 15:19
How do I get the displayed text to use white. I presume I need to add a class to this:<span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span> but what class would it be.

Bob

Julie
07 Jan 2006, 00:21
How do I get the displayed text to use white. I presume I need to add a class to this: but what class would it be.

Bob

You can add a colour to the smallfont class. Just go into your Style Manager, choose skin, Main CSS, and find Small Font. Just remember that any other thing using the smallfont class, will also have the same colour you specify.

firstrebel
07 Jan 2006, 12:57
Might be safer to make a new class just for this. Thanks

Bob

Gunshot
09 Jan 2006, 07:47
works well


but


after installing the left_column hack the compression stats seem to show up at the bottom of the column

and also on the "thank you for logging on" screen


how do we get rid of this or the stats altogether?

Gunshot
09 Jan 2006, 08:00
okay

I used post #149 to get rid of the stats

and post #30 to boost from 5% to 15% compression

Submerge
09 Jan 2006, 20:20
How do I get the compressor to show the line breaks when I go into Advanced Edit? It takes out the line breaks from posts in advanced edit.

rlamego
09 Jan 2006, 20:47
Submerge, that's the paragraph bug everyone is complaining about.

firstrebel
09 Jan 2006, 21:16
okay

I used post #149 to get rid of the stats

and post #30 to boost from 5% to 15% compression
Tried this and yes it does increase compression, but it broke my headers.

Bob

tantawi
09 Jan 2006, 22:29
Great hack, but any fix to the paragraph bug? :(

steven s
10 Jan 2006, 00:18
Great hack, but any fix to the paragraph bug? :(Nope. I can't use it until it is fixed. :(

jw00dy
10 Jan 2006, 00:33
Excellent mod! My dialup users will love you forever!

Julie
10 Jan 2006, 00:47
I'd like to re-install this as well... It's just the space-bug that's killing it for me. Many of my users like to add extra spacing in titles, etc, and this kills them :S

Daracon
11 Jan 2006, 10:59
Nope. I can't use it until it is fixed. :(

I'm waiting for the fix too.

ryuji
11 Jan 2006, 12:00
im using the new code, but when i used the code from the download link it didnt break the advanced editor, it didnt do more tne 3-5% tho either that or a random code edit i did earlier fixed it if this is true ill figure out what i did if you ppl want

tantawi
11 Jan 2006, 12:04
im using the new code, but when i used the code from the download link it didnt break the advanced editor, it didnt do more tne 3-5% tho either that or a random code edit i did earlier fixed it if this is true ill figure out what i did if you ppl want

Please :) Thanks.

DruidToolz
11 Jan 2006, 17:03
Ok i am kinda having a small problem... Before i installed this plugin i didn't have this [Output: 23.91 Kb. compressed to 22.99 Kb. by saving 0.92 Kb. (3.87%)] .. Showing at the bottom of the forum.. Can someone please tell me how to edit this xml file to get rid of that info at the bottom.. Thanx

tantawi
11 Jan 2006, 17:24
Ok i am kinda having a small problem... Before i installed this plugin i didn't have this [Output: 23.91 Kb. compressed to 22.99 Kb. by saving 0.92 Kb. (3.87%)] .. Showing at the bottom of the forum.. Can someone please tell me how to edit this xml file to get rid of that info at the bottom.. Thanx

Remove this:

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

$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);

snakes1100
11 Jan 2006, 17:56
[Output: 70.26 Kb. compressed to 65.76 Kb. by saving 4.50 Kb. (6.41%)] - forum home

[Output: 35.66 Kb. compressed to 33.45 Kb. by saving 2.21 Kb. (6.20%)] - forum display, one of the bigger categories with a lot of forums.

[Output: 69.04 Kb. compressed to 63.66 Kb. by saving 5.38 Kb. (7.80%)] - Individual forum

This is running on 3.5.3, all edit functions with wysig work correctly.

firstrebel
11 Jan 2006, 18:03
[Output: 70.26 Kb. compressed to 65.76 Kb. by saving 4.50 Kb. (6.41%)] - forum home

[Output: 35.66 Kb. compressed to 33.45 Kb. by saving 2.21 Kb. (6.20%)] - forum display, one of the bigger categories with a lot of forums.

[Output: 69.04 Kb. compressed to 63.66 Kb. by saving 5.38 Kb. (7.80%)] - Individual forum

This is running on 3.5.3, all edit functions with wysig work correctly.
Is this with the standard plugin or have you modded it?

Bob

snakes1100
11 Jan 2006, 18:12
Latest download, no modifications.

Confirmed to work in 3.5.3

snakes1100
11 Jan 2006, 18:19
Two screen shots to confirm no issue with advanced editor or spacing issues with post titles.

snakes1100
11 Jan 2006, 18:26
I'd like to re-install this as well... It's just the space-bug that's killing it for me. Many of my users like to add extra spacing in titles, etc, and this kills them :S


I have tested this on 3.5.3, before the plugin, in titles adding 10 extra spaces in between two words on a new post title, the extra spacing was stripped away by default.

This addon is not the cause as far as i can tell.

Added Note:
Want to thank ShiningArcanine & Logican for their work, great mod and good savings for the site.

ryuji
11 Jan 2006, 23:17
these are the results of my experiments with the code... this one doesnt break anything and ill see if i can figure out a way to make it not bust javascript

//Logician Hack:
//$page_byte=strlen($output);

//this broke scripts on my setup, if you want to test, click on 'more' smileys in advanced editor or try to bring up the user popup when you click on there name on a thread
//$output=preg_replace ('/(\s*)\r\n(\s*)/', "", $output);
//this broke scripts on my setup, if you want to test, click on 'more' smileys in advanced editor or try to bring up the user popup when you click on there name on a thread


$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);


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

//$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);
//Logician Hack:

remove the comments to re-enable the compression efficiency dialog

rootnik
12 Jan 2006, 20:05
Works good, but kills javascript roll overs in my headers. :disappointed:

exegete
13 Jan 2006, 08:58
The solution to the paragraph bug is to alter the regular expression in such a way that newline characters appearing between textarea tags are left untouched.

I leave this as an exercise for the reader. :)

tantawi
14 Jan 2006, 22:34
The solution to the paragraph bug is to alter the regular expression in such a way that newline characters appearing between textarea tags are left untouched.

I leave this as an exercise for the reader. :)

Any reader in there? :D

interceptor
15 Jan 2006, 08:44
Works great on 3.5.3 Install

Ramsesx
15 Jan 2006, 11:56
Works good, but kills javascript roll overs in my headers. :disappointed:
Installed with 3.5.0 and my button rollovers are working fine.
[Output: 177.75 Kb. compressed to 148.49 Kb. by saving 29.27 Kb. (16.46%)] Forumhome
[Output: 121.07 Kb. compressed to 115.58 Kb. by saving 5.49 Kb. (4.53%)] CMPS
[Output: 260.35 Kb. compressed to 244.70 Kb. by saving 15.64 Kb. (6.01%)] Forum Thread
[Output: 139.21 Kb. compressed to 134.20 Kb. by saving 5.01 Kb. (3.60%)] VB Gallery Home
[Output: 205.49 Kb. compressed to 203.91 Kb. by saving 1.59 Kb. (0.77%)] Links Directory

Club3G
15 Jan 2006, 17:00
As in the original XML: CMPS: [Output: 67.37 Kb. compressed to 66.30 Kb. by saving 1.07 Kb. (1.59%)]
Index: [Output: 81.60 Kb. compressed to 79.29 Kb. by saving 2.31 Kb. (2.83%)]
Forumdisplay: [Output: 104.74 Kb. compressed to 98.30 Kb. by saving 6.44 Kb. (6.15%)]

And now with this added:
$output=preg_replace ('/<!-- .*? -->/',"",$output);

CMPS: [Output: 67.15 Kb. CMP 64.81 Kb. Net 2.35 Kb. (3.50%)]
Index: [Output: 81.83 Kb. CMP 76.14 Kb. Net 5.69 Kb. (6.95%)]
Forumdisplay: [Output: 99.72 Kb. CMP 90.69 Kb. Net 9.03 Kb. (9.05%)]

Stripping the comments works really, really well. No bugs at all in 3.5.3 with plenty of mods. One thing I wouldn't mind seeing added is something that keeps a running tally of the total compressed kB savings. It'd be great to know at the end of the month just how much this is saving me. Also being able to only display this to admins would be ultimate. I'd strip the output code altogther, but I'm way too much of a dork to go without it. :D

Quick math for http://www.sevenstring.org

Average hits per day over the last week: 220880
Avg hits * 9.05k savings: 1998964
Average bandwith savings over 30 days: 1.90636 GB

Solid mod. Thanks much.

/me clicks install

Club3G
16 Jan 2006, 00:54
Bah, spoke too soon. Also have the paragraph bug. ;(

Submerge
16 Jan 2006, 01:57
The solution to the paragraph bug is to alter the regular expression in such a way that newline characters appearing between textarea tags are left untouched.

I leave this as an exercise for the reader. :)
Not all of us are php experts :(

Smiry Kin's
16 Jan 2006, 02:25
donno if its cos im on 3.5.2

but i get:

XML Error: unknown at Line 0

Club3G
16 Jan 2006, 02:27
The solution to the paragraph bug is to alter the regular expression in such a way that newline characters appearing between textarea tags are left untouched.

I leave this as an exercise for the reader


Not all of us are php experts :(

That's coder-speak for "I don't know how to do it". ;)

Even if the mod is bugged, IMHO it's still worth running on bigger forums if bandwidth is a concern.

ryuji
16 Jan 2006, 14:52
my variation of the script doesnt have the paragraph or javascript bugs, just dont uncomment the code i commented out as breaking stuff

natralis
16 Jan 2006, 17:18
works great for me
cheers

[Output: 42.78 Kb. compressed to 39.45 Kb. by saving 3.33 Kb. (7.77%)]

Totti
16 Jan 2006, 17:28
these are the results of my experiments with the code... this one doesnt break anything and ill see if i can figure out a way to make it not bust javascript

//Logician Hack:
//$page_byte=strlen($output);

//this broke scripts on my setup, if you want to test, click on 'more' smileys in advanced editor or try to bring up the user popup when you click on there name on a thread
//$output=preg_replace ('/(\s*)\r\n(\s*)/', "", $output);
//this broke scripts on my setup, if you want to test, click on 'more' smileys in advanced editor or try to bring up the user popup when you click on there name on a thread


$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);


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

//$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);
//Logician Hack:

remove the comments to re-enable the compression efficiency dialog


so that is the best working code at the moment?
still any known bugs then?

Club3G
16 Jan 2006, 20:19
I'm running that code, only the advanced editor bug. (It strips line breaks if you edit a post in advanced mode). Other than that, no problems whatsoever.

Riuji, unless you see a difference between my code and yours (I don't).

//Logician Hack:
$page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);

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

$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. CMP <b>' . $pagenew_kilobyte . '</b> Kb. Net <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center>
<br></body>', $output);
//Logician Hack:


I'd LOVE to see it keep a running tally in the admincp of kb saved.

ryuji
17 Jan 2006, 00:02
I'm running that code, only the advanced editor bug. (It strips line breaks if you edit a post in advanced mode). Other than that, no problems whatsoever.

Riuji, unless you see a difference between my code and yours (I don't).

//Logician Hack:
$page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);

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

$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. CMP <b>' . $pagenew_kilobyte . '</b> Kb. Net <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center>
<br></body>', $output);
//Logician Hack:


I'd LOVE to see it keep a running tally in the admincp of kb saved.


i dont have the advanced mode issue you speak of does it go away if you comment out the code for the file size savings?

Club3G
17 Jan 2006, 01:14
Nope, it still does it. :(

ryuji
17 Jan 2006, 13:22
what version of vbb are you running and try commenting out the replacment lines and figure out just which one is breaking the advanced editor

Carnage
17 Jan 2006, 15:03
ok, well here is your solution to all the bugs. One problem is its in english and not php...

You need to parse out multiple white spaces + newlines in all of the code, you also need to remove html comments. HOWEVER you must ignore anything between <pre> <textarea> and <script> tags.

Ok well theres the brief... i'll see what i can do in a bit. (I think a good starting place would be to see how Vb3.5 handles bb tags especially the [nocode] tag or whatever it is that prevents bb code parsing between it.)

edit:
Well i've been messing arround for a bit and havn't got anywhere... The only 'hacked' solution i could come up with is to match the text area tags to a variable do the white space removal and put the text areas back in again.

ryuji
18 Jan 2006, 05:07
when i get bored ill try my hand at making it conditional... but with my setup it appears immune to the issue unless i use the commented out line of code instead of what i actualy had enabled

Carnage
18 Jan 2006, 05:12
this problem is really bugging me now... i haven't been able to come up with a singal working regex expression...

Chris-777
18 Jan 2006, 17:33
Leaving it installed but disabling it for now. The linebreaks in advanced mode are just impossible to work around.

Chris-777
19 Jan 2006, 04:42
Can this be modded to only strip commented out code?

ryuji
19 Jan 2006, 11:33
yes. comment out the fist replacment command

voleibolmurcia
20 Jan 2006, 14:55
How could i make that the text...

[Output: 37.45 Kb. compressed to 36.00 Kb. by saving 1.45 Kb. (3.87%)]

be in the same color that the background?

I dont find the template o the code in the footer for this hack.

Thank u.

Chris-777
20 Jan 2006, 15:33
How could i make that the text...

[Output: 37.45 Kb. compressed to 36.00 Kb. by saving 1.45 Kb. (3.87%)]

be in the same color that the background?

I dont find the template o the code in the footer for this hack.

Thank u.

From what I can tell by reading the thread a few times (don't hold me to this) the compression, and that expression, are processed before the templates themselves.

Your best bet is to try editing the plugin itself.

ryuji
20 Jan 2006, 17:07
From what I can tell by reading the thread a few times (don't hold me to this) the compression, and that expression, are processed before the templates themselves.

Your best bet is to try editing the plugin itself.
actualy... what he wants to change is processed after the page is completely made... so its after the templates

Dave-ahfb
20 Jan 2006, 23:10
just open the xml and find this line

$output = str_replace('</body>', '<center><span class="smallfont">[Output: ' . $page_kilobyte . ' Kb. compressed to <b>' . $pagenew_kilobyte . '</b> Kb. by saving <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></body>', $output);

dodgechargerfan
21 Jan 2006, 01:08
So far so good. Even the paragraph issue seems to not be a problem.

*clicks install*


Edit: I should have mentioned that I am running 3.5.3.

XFSImperial
21 Jan 2006, 02:32
Nice hack, works fine on 3.5.3 :D

bada_bing
21 Jan 2006, 03:41
I would like to hear some feedback on people running this in vb 3.5.3 and if they had any problems

derekivey
21 Jan 2006, 04:36
I'm running it on my site, and I am having no problems with it :). It's working flawlessly for me.

Dave-ahfb
21 Jan 2006, 04:43
I am running it on 3.5.3...no problems

netcommander
21 Jan 2006, 15:39
I am testing it on 3.5.3 I will write again

thedvs
21 Jan 2006, 16:13
anyway to put the output in a nice place, some of us use custom skins and the output looks horrible outside the skin gfx and ruins the look of the board

any suggestions appreciated

ryuji
21 Jan 2006, 17:33
the issue is enable to calculate the space savings it needs to be completely done processing the page... just disable it.. all it does is use up more bandwith lol


seems that i am correct in earlier thinking that the issues are gone with 3.5.3?

darksoulz
21 Jan 2006, 18:04
we're on 3.5.3 and haven't noticed any problems.

Chris-777
21 Jan 2006, 18:21
I'm on 3.5.3 and it strips line breaks if I advanced-edit a post. The only way I get around it is by commenting out:


//$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);

Chris-777
21 Jan 2006, 18:22
yes. comment out the fist replacment command


//Logician Hack:
$page_byte=strlen($output);
//$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);

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


That's the current contents of the plugin. If I'm understanding it correctly, I shouldn't see things like:

<!-- header Gallery Links-->

When I view my source if the comments are being stripped, correct? One of the main reasons is that I've been writing code for a living for ages now, and I tend to comment the hell out of every change I make. So people viewing my source tend to see some rather interesting comments. ;)


<!-- What the @#@$ did I screw up this time? -->


Because right now, this is my compression "Savings".


[Output: 0.00 Kb. compressed to 82.54 Kb. by saving -82.54 Kb. (0.00%)]


:(

ryuji
22 Jan 2006, 16:43
put a space before the --> there was a issue with it taking out code it wasnt supposed to.. i introduced the space before the -->

Chris-777
22 Jan 2006, 17:26
/me scratches his head

There's a space in the original code snippet I posted, but I put another one in anyhow. ;)


//Logician Hack:
$page_byte=strlen($output);
//$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);


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


Still no love from that, I'm still seeing all of my commented stuff. :(

(Thank you very much for the help btw, ryuji, I appreciate you takin' the time to help me sort this out. :) )

Chris-777
22 Jan 2006, 17:38
anyway to put the output in a nice place, some of us use custom skins and the output looks horrible outside the skin gfx and ruins the look of the board

any suggestions appreciated

This won't move it, but if you at least want to change the look of it, add a CSS to you your MAIN statement for it, something like:


.compressor
{
color: #2886B6;
font: 10px verdana;
}

And then change the span class="smallfont" tag in the plugin itself to span class="compressor".

http://www.sevenstring.org/chris/comptext.jpg

On a nother note, I'd love it if someone could find a way to make this conditional work. I've tried it in a few places and haven't found something to make it happen.

$output = str_replace('</body>', '<if condition="in_array($bbuserinfo['usergroupid'], array(6))"><center><span class="compressor">[O: ' . $page_kilobyte . ' Kb C:<b>' . $pagenew_kilobyte . '</b> Kb. S: <b>' . $pagesaved_kilobyte . '</b> Kb. (' . $pagesaved_perc . '%)]</span></center></if></body>', $output);
//Compressor

Submerge
22 Jan 2006, 20:59
Running it on 3.5.3 and getting the paragraph break problem on Advanced Edit

ryuji
22 Jan 2006, 23:40
* Chris-777 scratches his head


There's a space in the original code snippet I posted, but I put another one in anyhow. ;)


//Logician Hack:
$page_byte=strlen($output);
//$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);
$output=preg_replace ('/<!-- .*? -->/',"",$output);


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


Still no love from that, I'm still seeing all of my commented stuff. :(

(Thank you very much for the help btw, ryuji, I appreciate you takin' the time to help me sort this out. :) )
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

Smiry Kin's
23 Jan 2006, 01:01
with 3.5.2

and element skil.

it messes up the DHTML thing.. which is a pain really.. any way to sort this?

mox-
23 Jan 2006, 11:35
Wow, I just installed it and it seems to be working fine.

Is there a way to remove all <!-- comments --> in the code ? This would save a lot too.

Totti
23 Jan 2006, 13:50
mox- read the thread ... :D
All the last posts are about it ;)

My problem is that i got some
<!--
bloa
bla
blubb
-->
code which is not stripped at all ... any way sorting it out beside making it one line with <!-- xxx --> in code?!?

lightwave
23 Jan 2006, 16:04
where did you guys upload it tooo

Chris-777
23 Jan 2006, 17:17
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:


<!--This is my comment-->

That I need to change them to:

<!-- This is my comment -->

Like that?

ryuji
23 Jan 2006, 18:51
thats all i had to do.. and it solved issues with the scripts

Hellcat
25 Jan 2006, 02:30
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 :)

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

Chris-777
25 Jan 2006, 03:00
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.

Chris-777
25 Jan 2006, 03:02
For reference, a screeny of my forums using my existing code, which only strips comments.

Hellcat
25 Jan 2006, 03:49
Hmm.... I think I know what that might cause....
If that's it it would reduce the ratio, but increase compatibility....
/me starts tweaking :)

[EDIT]
OK, try this:

In my above posted code, find theese two lines:
$output = str_replace( "\n" , "" , $output );
$output=preg_replace('/<!-- .*? -->/', "", $output);
and replace them by those:
$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....

/me waits for feedback now :)

The Chief
25 Jan 2006, 04:29
does this work with vB Drupal?

Hellcat
25 Jan 2006, 04:32
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....

The Chief
25 Jan 2006, 04:36
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?

The Chief
25 Jan 2006, 04:39
and the result is: Nope it doesn't work with vb drupal...

works fine for my forums though so installed...

/me clicks install