[TYPO3-dev] Javascript Minify-Manager

Sebastian Gebhard s.gebhard at markenmotiv.de
Thu Mar 5 12:15:41 CET 2009


Hi list,

i'm sure something like this was already discussed, and if so i'd be 
glad if you could give me a link.

Anyway i'll share my thoughts:

TYPO3 Backend and on some Websites also FE is full of JS-Files. But most 
of them are not minified.

Here's my suggestion:

Why not registering all needed Javascript on a central place while page 
rendering and then create a single file with all needed javascript which 
is minified (using the already existing JSMin).
Sounds like a lot of PHP processing? We could use the same concept we 
use for thumbnail images.
Let's say a page needs script.js, library.js and "window.onload = 
alert('hi!');"

Now a shortMd5 hash of these options is generated and the minified 
single file is named like the hash, e.g. 0ee83dbdf8.js
Now when the same page is called again with the same JS requirements 
this file does not need to be generated.

Such a manager should be accesible via TS, via PHP and should also take 
the code from removeDefaultJS = external if set.

E.g. from PHP something like

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

This would be written into an array by those static methods. In the end 
all contents of the files and all script snippets are merged and minified.

What do you think?




More information about the TYPO3-dev mailing list