[TYPO3-dev] prototype and compressed

Jerome Schneider typo3dev at ameos.com
Thu Mar 13 11:18:24 CET 2008


Hi,

I'm using pre-processed minified and gzipped javascript to serve 
prototype and other js libraries, and it works just great with real size 
deflation.

regular prototype + my other js files => 166KB
same, minified => 120KB
same, minified+gzip'd => 31KB !!

To serve gzipd js, you'll need this HTTP header:

Content-encoding: gzip

I use this piece of code to add this header this without any need of 
apache's mod-deflate:

<?php
	header("Content-Type: text/javascript");
	header("Content-Encoding: gzip");
	header("Cache-Control: max-age=86400, public");
	fpassthru(fopen(realpath("./formidable.minified.js.gz"), "rb"));
	exit;
?>

And then tell the browser that javascript is hosted at the address of 
this php-script.


I tested this on Firefox windows, Safari windows/osx, IE6/7 and Opera 
windows, and it worked just fine.

Improvement would be to check if client accepts content-encoding gzip.

Bye,
Jerome Schneider





Steffen Kamper a écrit :
> "Dmitry Dulepov [typo3]" <dmitry at typo3.org> schrieb im Newsbeitrag 
> news:mailman.1.1205323571.29067.typo3-dev at lists.netfielders.de...
>> Hi!
>>
>> Steffen Kamper wrote:
>>> BE nearly always include prototype library, sometimes scriptacolous. The 
>>> libraries are uncompressed all the time.
>>> This is good for debugging, but not for performance.
>>>
>>> I would like to have a switch to use compressed libraries, this could 
>>> speed up BE.
>> Hint: you can use t3lib_div::minifyJS to compress it. Why we may need a 
>> switch?
>>
>> -- 
> 
> because prototype.js is included as it is without JSprocessing. I see 2 
> possibilities:
> 
> 1) centralize the inclusion of prototype, maybe in t3lib_div and process the 
> switch wether it should be minified or not
> 2) use switch in every manual inclusion
> 
> I would prefer to use the delivered compressed lib instead doing it with 
> minify as the compressed lib is improved and no time for conversion is 
> needed
> 
> vg  Steffen 
> 
> 




More information about the TYPO3-dev mailing list