Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Please add some minifier or packer script before the compression to gzip...
it would be great...
Thanks
Comment | File | Size | Author |
---|---|---|---|
#3 | YuiBatch.zip | 1.27 KB | gremlinc5 |
Comments
Comment #1
gremlinc5 CreditAttribution: gremlinc5 commentedbecause of the nature of smartcache, adding minifying could be difficult.
Best minifiers around (yui compressor by Julien Le Comte) are not written in php, so it would be tricky to implement them.
The best thing you can do is write a script that:
1 - connects to your site via ftp
2 - downloads every js and css file
3 - runs iteratively the compressor over them
4 - uploads the compressed files to your site
This way, every time you update your Drupal site, you can rerun your minifying script.
It's not that difficult (I did it once in a .bat file, but I can't find it anymore, sorry)...
I'll see if I can find it somewhere.
Comment #2
panji CreditAttribution: panji commentedyup,.. coz it would be so long if I should minified them every time I update the module, etc etc,.. and YUI Compressor can't be used as a compressor on the fly,.. what about other compressor like jsmin?
humm anyway, please let me know if You've found the .bat file
thanks
Comment #3
gremlinc5 CreditAttribution: gremlinc5 commentedJSMin is not that good, so I prefer to compress the production js files offline and reupload them.
GZipping js and css with or without JSMin-ifying them is not that different, so I did not bother to implement a possibly buggy minifyer.
In fact, it's a really hard topic, so I prefered to totally avoid it and stick with a simple and optimizable task (zip compression), rather than try to make a buggy minifyer no one would use.
About thje batch script, I think I lost it, but I found the minify part.
Attached you'll find an archive. Inside there is the bat file and the directory tree.
The batch file:
Basically it copies every js and css file from the SourceFiles folder to the Compressed folder, then calls yuicompressor iteratively on it.
There is no ftp part on this batch, so you'll have to manually copy your js files to the SourceFiles folder and reupload them.
Or use a tool like rsync and modify the batch accordingly. I can't do this myself at the moment, sorry.
Note that to setup this you have to copy the file yuicompressorxxx.jar into the YUIBatch directory AND RENAME it into yuicompressor.jar.
Hope it helps...
Bye
Comment #4
ibandyop CreditAttribution: ibandyop commentedPerhaps you can integrate this PHP minifier. http://code.google.com/p/jsmin-php/ ( As an option for those who want to try )