PDA

View Full Version : Template Compressor


VBCoder
07 Jul 2005, 03:58
PROBLEM: Pages are produced with huge amounts of white space, comments, etc., bloating the HTML, load time, and bandwidth.

SOLUTION: Compress it. Remove whitespace, etc.

PROBLEM: This takes CPU time.

SOLUTION: Precompress the templates. That is, store two copies of each template. A "master", which is showed when you edit, and a "compressed", which is generated each time you save a new template (or edit one), without whitespace and comments. The compressed one is actually used.

Anyone up to the challenge?

Biker_GA
07 Jul 2005, 04:06
http://www.vbulletin.org/forum/showthread.php?t=83248 ;)

Dream
07 Jul 2005, 04:10
the same template content is stored in two columns, not sure why, one is used in eval() I think, you could compress that one I think

Biker_GA
07 Jul 2005, 04:13
With compression -

Powered by vBulletin Version 3.5.0 Beta 3
Copyright 2000 - 2005, Jelsoft Enterprises Ltd.

[Output: 25.91 Kb. compressed to 24.95 Kb. by saving 0.96 Kb. (3.69%)]
Page generated in 0.09913 seconds with 8 queries [Server Loads: average: 0.50, 0.81, 0.85 0.50 : 0.81]

Without compression -

Powered by vBulletin Version 3.5.0 Beta 3
Copyright 2000 - 2005, Jelsoft Enterprises Ltd.

Page generated in 0.09982 seconds with 8 queries [Server Loads: average: 0.61, 0.74, 0.81 0.61 : 0.74]

VBCoder
07 Jul 2005, 04:35
Biker, I saw that plug in, but it compresses each page as it is served. As I said, this could be further optimized by just compressing the template. See PROBLE #2.

(I have in mind some additional compressions, that would take more time, and hence are best done only once).

Biker_GA
07 Jul 2005, 04:39
Biker, I saw that plug in, but it compresses each page as it is served. As I said, this could be further optimized by just compressing the template. See PROBLE #2.

(I have in mind some additional compressions, that would take more time, and hence are best done only once).
You may wish to read the hack again. It is a template compressor. Not a page compressor.

Andreas
07 Jul 2005, 04:43
the same template content is stored in two columns, not sure why, one is used in eval() I think, you could compress that one I think

Performance :)

PHP obviously doesn't understand <if> ... <else />, <phrase>.
So this has to be parsed into native PHP Calls, and if this would be done for every Template upon every Page Call it would be a mjaor performance hit.


Compressing the Templates Offline is a good idea, unfortunately there a a bunch of Problems - JavaScript for example.