[TYPO3-dev] Javascript Minify-Manager

Thomas Allmer at at delusionworld.com
Thu Mar 5 22:13:35 CET 2009


Sebastian Gebhard wrote:
> t3lib_jsmgm::addFile('path/script.js');
> t3lib_jsmgm::addScript("window.onload = alert('hi!');");

how about:

t3lib_jsmgm::addFile('path/script.js', 1);

if the file is already compressed. This way the manager could provide 
one single file (one request) per page and don't have to minify everything.

So if for example you want to include the ExtJS Core it should be 
already minified. But for small scripts you write for your extensions 
you don't need to worry about just include it...

you could also create "categories" if people really want to. Something like

t3lib_jsmgm::addFile('path/script.js', 1, 'core');
t3lib_jsmgm::addFile('path/script2.js', 0, 'core');

t3lib_jsmgm::addFile('path/script3.js');
t3lib_jsmgm::addFile('path/script4.js');

So by this the core minified file will be included all the time and does 
not change (hence you can use the client side browser cache) however the 
other scripts are more likely to change so the will be included in 
another request...

In this small example you have overall 2 requests, one for the "basics" 
(means frameworks; things you need on every page; mostly pre-minified) 
and one for the "normale" scripts (like function you need for you 
special extension)

I think this way
- you don't need to minify everything on the fly
- you can use the local browser cache
- still have a single manager
- far fewer requests
- and mostly you don't need to care about minifying scripts yourself...

should be worth it?

cheers
-- 
+---------------------------------+-----------------------------------+
| Thomas Allmer                   |   http://www.delusionworld.com    |
| E-mail: at at delusionworld.com    |   phone: +43 699 16217064         |
+---------------------------------+-----------------------------------+




More information about the TYPO3-dev mailing list