PDA

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


Pages : [1] 2

ShiningArcanine
06-16-2005, 10:00 PM
This is a port of Logican's Realtime Template Compressor hack (https://vborg.vbsupport.ru/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
06-16-2005, 10:57 PM
Forgetting something?

Robert Basil
06-16-2005, 11:09 PM
Yup, looks like the xml file might help. ;)

Martin
06-17-2005, 12:17 AM
Yup, looks like the xml file might help. ;)

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

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

Martin
06-17-2005, 01:51 AM
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
06-17-2005, 01:57 AM
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
06-17-2005, 03:52 AM
Did you contact the original author for permission to port his hack?

kall
06-17-2005, 04:50 AM
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
06-17-2005, 06:03 AM
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
06-17-2005, 06:28 AM
Oops

/me makes a mental note to read better before replying

ultranerds
06-17-2005, 10:47 AM
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
06-17-2005, 05:06 PM
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
06-17-2005, 05:13 PM
*Installing now*

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

ShiningArcanine
06-17-2005, 05:23 PM
*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
06-17-2005, 05:28 PM
That messed up my tables.

ShiningArcanine
06-17-2005, 05:41 PM
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
06-17-2005, 05:45 PM
oh, ok. I'll try that.

womensden
06-17-2005, 05:47 PM
That worked! Thanks

mholtum
06-17-2005, 06:13 PM
[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
06-17-2005, 06:30 PM
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
06-17-2005, 07:32 PM
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
06-17-2005, 08:10 PM
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
06-17-2005, 08:15 PM
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
06-17-2005, 08:39 PM
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
06-17-2005, 08:53 PM
What about that

The following line has 4 spaces at the beginning
Test

ShiningArcanine
06-17-2005, 09:22 PM
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
06-17-2005, 10:13 PM
This is the stock [code] Tag :)
It generates <pre>-Tags, which should preserve whitespaces - but you strip them out.

ShiningArcanine
06-17-2005, 10:36 PM
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
06-18-2005, 06:47 AM
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
06-18-2005, 06:48 AM
[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
06-18-2005, 12:16 PM
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
06-18-2005, 12:47 PM
Very nice hack idea - So far no odd looking tables or anything, and I'm getting about 5% compression :)

Satan

Martin
06-18-2005, 09:44 PM
Installed using ja3's code and showing arounf 18-19% compression

womensden
06-18-2005, 10:32 PM
I get a lot better compression with ja3's code as well.

womensden
06-18-2005, 10:54 PM
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
06-18-2005, 10:57 PM
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
06-19-2005, 04:03 AM
Martin, would you give me specific instructions on how to reproduce that because I can't seem to reproduce it on my own?

Martin
06-19-2005, 05:55 AM
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
06-19-2005, 06:05 AM
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
06-19-2005, 06:07 AM
I think what it's doing is killing the space in the XML compliant line break, breaking it

<br />

becomes <br/>

ja3
06-19-2005, 06:22 AM
Hmm strange. It doesnt happen here.

Martin
06-19-2005, 06:27 AM
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
06-19-2005, 10:19 AM
Will this work for 3.0.7? I dont see the "Plugin System" in the Admin Control Panel.

Thanks.

womensden
06-19-2005, 12:58 PM
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
06-19-2005, 01:04 PM
i use what ja3 said i get better compression with that


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

ja3
06-19-2005, 05:28 PM
I found a little error in my code, fixing this asap :)

ShiningArcanine
06-20-2005, 08:32 PM
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
06-21-2005, 06:36 PM
3.0.7 doesn't have the plugin system.

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

Martin
06-21-2005, 09:25 PM
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
06-22-2005, 02:41 AM
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
06-22-2005, 04:52 AM
Could this hack please be uploaded as a zip-file.

Thank you.

merk
06-22-2005, 05:52 AM
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
06-23-2005, 09:10 PM
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
07-01-2005, 01:35 AM
:) 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
07-01-2005, 01:59 AM
work on b3?

Chris M
07-01-2005, 10:30 AM
Does for me :)

Satan

MentaL
07-01-2005, 02:05 PM
Installed and featured on www.ragezone.com

shiva
07-16-2005, 08:48 AM
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
07-27-2005, 12:48 AM
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
07-28-2005, 02:00 AM
Glad to have this for 3.5. Seems to be working well! :)

safiel
07-30-2005, 09:38 PM
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
08-11-2005, 10:01 AM
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
08-11-2005, 12:56 PM
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
08-11-2005, 01:25 PM
What is the actual code that seems to be working best for everyone?

Cyricx
08-11-2005, 02:06 PM
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
08-17-2005, 07:23 AM
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
09-14-2005, 06:59 AM
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
09-14-2005, 02:55 PM
Confirmed here as well

paulius
09-18-2005, 03:43 AM
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
09-25-2005, 04:24 PM
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
09-28-2005, 02:43 AM
works great for me
my pages load so fast i didnt notice they changed
thanks....

SHANE-D-PAIN
09-28-2005, 04:42 PM
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
09-30-2005, 10:37 AM
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
10-02-2005, 07:39 AM
Yes same problem here,I'm already disable it...

jugo
10-03-2005, 04:08 PM
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
10-03-2005, 04:53 PM
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
10-04-2005, 11:45 PM
If I don't want any text information about compression, what should I delete from the xml-file?

jribz
10-05-2005, 06:51 AM
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: https://vborg.vbsupport.ru/showpost.php?p=775446&postcount=70

Fenriz
10-05-2005, 10:08 AM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$page_byte),2);and leave only $page_byte=strlen($output);
$output=preg_replace ('/\r\n(\s*)/', "\r\n", $output);

Yorixz
10-05-2005, 01:48 PM
Thanks a lot; up to 9% is still 18gb on 200gb monthly traffic ;)

richard4339
10-06-2005, 07:22 PM
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
10-07-2005, 07:36 PM
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
10-08-2005, 01:50 AM
smokering clicks install and heads off to plug it in plug it in

Neal-UK
10-08-2005, 07:55 AM
smokering clicks install and heads off to plug it in plug it in

appears to be working on vb 3.5 gold

vibe
10-09-2005, 06:22 AM
works
thanks

michaelbenson
10-09-2005, 09:01 AM
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
10-09-2005, 09:05 AM
work with vB 3.5 gold ?

piXelatedEmpire
10-09-2005, 09:18 AM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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-10-2005, 01:32 AM
Great hack, thanks!!!

PennylessZ28
10-10-2005, 03:20 AM
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-10-2005, 03:52 AM
Well so far so good, I am not getting 20% or even 10% but it seems a little better. Thank You

piXelatedEmpire
10-10-2005, 08:32 AM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
10-11-2005, 01:47 PM
Works for me, thanks! :)

Andreas
10-11-2005, 03:25 PM
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
10-11-2005, 04:45 PM
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
10-11-2005, 04:51 PM
thanks kirby for the update

Emil
10-11-2005, 08:33 PM
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
10-12-2005, 02:36 PM
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
10-12-2005, 04:36 PM
Does anyone know how (or where) to add the if conditional to show the stats on pages only to admins?
anyone?

Julie
10-12-2005, 05:15 PM
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
10-12-2005, 05:18 PM
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
10-12-2005, 07:11 PM
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
10-12-2005, 08:58 PM
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
10-14-2005, 12:24 PM
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
10-17-2005, 08:54 PM
Advanced Thread Previews get all the paragraphs stripped if you edit a thread. Quick AJAX edits keep the paragraphs. Fix?

dethfire
10-17-2005, 10:53 PM
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
10-22-2005, 12:29 AM
Anyone with a fix on this or should I uninstall?

Samira
10-25-2005, 11:34 PM
Had to uninstall until the editor issue is fixed.

glorify
10-25-2005, 11:48 PM
Me too. :(

FleaBag
10-27-2005, 11:04 PM
I actually reported this as a 3.5 Beta bug oops heh... I have uninstalled until a fix comes along also. :)

PET
11-09-2005, 07:01 AM
so it's not safe to install ?

steven s
11-09-2005, 09:42 AM
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
11-09-2005, 10:22 AM
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
11-09-2005, 10:33 AM
sounds like it has alot of bugs.. let us know when the Final Release is ready...

steven s
11-19-2005, 10:03 PM
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
11-20-2005, 12:56 AM
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
11-20-2005, 01:07 AM
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
11-21-2005, 03:27 AM
works fine on 3.5.1 forum .. no bugs or complains :)

Unexplained.tv
11-21-2005, 04:07 AM
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
11-21-2005, 04:36 AM
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
11-21-2005, 03:55 PM
is this safe to use or it still contains bugs ??

dethfire
11-21-2005, 04:06 PM
is this safe to use or it still contains bugs ??

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

Dead End Society
11-21-2005, 04:09 PM
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
11-22-2005, 02:42 PM
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
11-23-2005, 09:12 PM
Great Hack, I can definitely put this to use.

Thanks!

Bounce
11-23-2005, 10:09 PM
Installed thanks :nervous:

Chadi
11-23-2005, 10:26 PM
Anyway to remove the actual statistic "quiried in xxx" line?

richard4339
11-24-2005, 04:22 AM
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
11-24-2005, 06:39 AM
Installs

Chadi
11-24-2005, 11:57 AM
Anyone else have a better answer?

lexx27
11-25-2005, 11:15 PM
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
11-25-2005, 11:17 PM
It works fine, no errors here

Running on vb 3.5.1

Detomah
11-26-2005, 08:55 AM
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
11-28-2005, 03:14 AM
Anyway to remove the actual statistic "quiried in xxx" line?

Anyone? :)

Chadi
12-04-2005, 02:38 AM
6 days now no answer :)

can someone please help? Thank you

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

steven s
12-09-2005, 11:51 AM
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
12-09-2005, 07:14 PM
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
12-10-2005, 04:55 AM
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
12-10-2005, 08:18 AM
works great for me with 3.5.2, *installed*

Rickie3
12-10-2005, 09:08 AM
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
12-10-2005, 07:47 PM
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
12-10-2005, 11:10 PM
[Output: 198.77 Kb. compressed to 189.96 Kb. by saving 8.81 Kb. (4.43%)]

its working great

Installed ;)

Stephen3
12-11-2005, 05:10 AM
so it's work on 3.5.2?

Brandon Sheley
12-11-2005, 06:55 AM
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
12-11-2005, 04:59 PM
Installed and Uninstalled on 3.5.2

Wont use until the advanced edit spacing is fixed.

Great idea however!

Chadi
12-12-2005, 01:08 AM
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-12-2005, 01:18 AM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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-12-2005, 02:29 AM
Thank you. That works :)

MissKalunji
12-13-2005, 04:20 AM
[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
12-13-2005, 03:49 PM
yeah this should be good

Heo13
12-14-2005, 06:32 AM
[Output: 84.84 Kb. compressed to 80.26 Kb. by saving 4.58 Kb. (5.39%)]

Seem good, but i want more compression :)

dethfire
12-14-2005, 03:31 PM
paragraph break bug still exists

Moparx
12-14-2005, 05:01 PM
paragraph break bug still exists

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

Mudvayne
12-14-2005, 06:05 PM
me clicked install :D

BiReL41r
12-16-2005, 07:57 PM
Does anybody know a percentage of the faster loading times on pages?

dreamer81
12-18-2005, 08:04 AM
only get about 5% so im gonna wait for something heavier...

Alviker
12-18-2005, 07:10 PM
Run in 3.5.1? ^^

Atte. Alviker

steven s
12-18-2005, 07:52 PM
Run in 3.5.1? ^^

Atte. Alviker
No reason why it wouldn't.

kau
12-19-2005, 12:29 AM
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
12-19-2005, 01:48 AM
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
12-19-2005, 04:27 AM
yeap..this is really too kool hacks..

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

Thnks

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

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

https://vborg.vbsupport.ru/showpost.php?p=846646&postcount=149 ?

wtrk
01-01-2006, 09:50 PM
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
01-05-2006, 01:41 AM
I noticed a huge difference. Great plug.

Submerge
01-05-2006, 03:43 AM
*Installed

Works great on 3.5.3!

Gripemaster
01-05-2006, 03:50 AM
*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
01-05-2006, 05:20 AM
thanks alot,

this is a great hack

firstrebel
01-06-2006, 01:19 PM
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
01-06-2006, 10:21 PM
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
01-07-2006, 10:57 AM
Might be safer to make a new class just for this. Thanks

Bob

Gunshot
01-09-2006, 05:47 AM
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
01-09-2006, 06:00 AM
okay

I used post #149 to get rid of the stats

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

Submerge
01-09-2006, 06:20 PM
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
01-09-2006, 06:47 PM
Submerge, that's the paragraph bug everyone is complaining about.

firstrebel
01-09-2006, 07:16 PM
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
01-09-2006, 08:29 PM
Great hack, but any fix to the paragraph bug? :(

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

jw00dy
01-09-2006, 10:33 PM
Excellent mod! My dialup users will love you forever!

Julie
01-09-2006, 10:47 PM
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
01-11-2006, 08:59 AM
Nope. I can't use it until it is fixed. :(

I'm waiting for the fix too.

ryuji
01-11-2006, 10:00 AM
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
01-11-2006, 10:04 AM
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
01-11-2006, 03:03 PM
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
01-11-2006, 03:24 PM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-11-2006, 03:56 PM
[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
01-11-2006, 04:03 PM
[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
01-11-2006, 04:12 PM
Latest download, no modifications.

Confirmed to work in 3.5.3

snakes1100
01-11-2006, 04:19 PM
Two screen shots to confirm no issue with advanced editor or spacing issues with post titles.

snakes1100
01-11-2006, 04:26 PM
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
01-11-2006, 09:17 PM
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_byt e)/1024),2);
//$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-12-2006, 06:05 PM
Works good, but kills javascript roll overs in my headers. :disappointed:

exegete
01-13-2006, 06:58 AM
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
01-14-2006, 08:34 PM
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
01-15-2006, 06:44 AM
Works great on 3.5.3 Install

Ramsesx
01-15-2006, 09:56 AM
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
01-15-2006, 03:00 PM
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.

* Club3G clicks install

Club3G
01-15-2006, 10:54 PM
Bah, spoke too soon. Also have the paragraph bug. ;(

Submerge
01-15-2006, 11:57 PM
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
01-16-2006, 12:25 AM
donno if its cos im on 3.5.2

but i get:

XML Error: unknown at Line 0

Club3G
01-16-2006, 12:27 AM
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
01-16-2006, 12:52 PM
my variation of the script doesnt have the paragraph or javascript bugs, just dont uncomment the code i commented out as breaking stuff

natralis
01-16-2006, 03:18 PM
works great for me
cheers

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

Totti
01-16-2006, 03:28 PM
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_byt e)/1024),2);
//$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-16-2006, 06:19 PM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-16-2006, 10:02 PM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-16-2006, 11:14 PM
Nope, it still does it. :(

ryuji
01-17-2006, 11:22 AM
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
01-17-2006, 01:03 PM
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
01-18-2006, 03:07 AM
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
01-18-2006, 03:12 AM
this problem is really bugging me now... i haven't been able to come up with a singal working regex expression...

Guest210212002
01-18-2006, 03:33 PM
Leaving it installed but disabling it for now. The linebreaks in advanced mode are just impossible to work around.

Guest210212002
01-19-2006, 02:42 AM
Can this be modded to only strip commented out code?

ryuji
01-19-2006, 09:33 AM
yes. comment out the fist replacment command

voleibolmurcia
01-20-2006, 12:55 PM
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.

Guest210212002
01-20-2006, 01:33 PM
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
01-20-2006, 03:07 PM
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
01-20-2006, 09:10 PM
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
01-20-2006, 11:08 PM
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
01-21-2006, 12:32 AM
Nice hack, works fine on 3.5.3 :D

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

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

Dave-ahfb
01-21-2006, 02:43 AM
I am running it on 3.5.3...no problems

netcommander
01-21-2006, 01:39 PM
I am testing it on 3.5.3 I will write again

thedvs
01-21-2006, 02:13 PM
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
01-21-2006, 03:33 PM
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
01-21-2006, 04:04 PM
we're on 3.5.3 and haven't noticed any problems.

Guest210212002
01-21-2006, 04:21 PM
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);

Guest210212002
01-21-2006, 04:22 PM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-22-2006, 02:43 PM
put a space before the --> there was a issue with it taking out code it wasnt supposed to.. i introduced the space before the -->

Guest210212002
01-22-2006, 03:26 PM
* Guest210212002 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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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. :) )

Guest210212002
01-22-2006, 03:38 PM
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
01-22-2006, 06:59 PM
Running it on 3.5.3 and getting the paragraph break problem on Advanced Edit

ryuji
01-22-2006, 09:40 PM
* 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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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
01-22-2006, 11:01 PM
with 3.5.2

and element skil.

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

mox-
01-23-2006, 09:35 AM
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
01-23-2006, 11:50 AM
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
01-23-2006, 02:04 PM
where did you guys upload it tooo

Guest210212002
01-23-2006, 03:17 PM
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
01-23-2006, 04:51 PM
thats all i had to do.. and it solved issues with the scripts

Hellcat
01-25-2006, 12:30 AM
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_byt e)/1024),2);
$pagesaved_perc=number_format(((100*$pagesaved_byt e)/$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);

Guest210212002
01-25-2006, 01:00 AM
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.

Guest210212002
01-25-2006, 01:02 AM
For reference, a screeny of my forums using my existing code, which only strips comments.

Hellcat
01-25-2006, 01:49 AM
Hmm.... I think I know what that might cause....
If that's it it would reduce the ratio, but increase compatibility....
* Hellcat 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....

* Hellcat waits for feedback now :)

The Chief
01-25-2006, 02:29 AM
does this work with vB Drupal?

Hellcat
01-25-2006, 02:32 AM
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
01-25-2006, 02:36 AM
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
01-25-2006, 02:39 AM
and the result is: Nope it doesn't work with vb drupal...

works fine for my forums though so installed...

/me clicks install