Features ΒΆ
- Javascript and CSS compression of Yii clientscript packages (using YUI compressor)
- Does not interfere with scripts and CSS registered outside of packages
- Automatic or manually triggered compression
- Locking mechanism to prevent multiple concurrent compressions
- Workaround for the thundering herd problem
- Command-line maintenance script
For all details please visit the github project page.
Best clientscript extension
The combination of scripts with their dependencies into a single file if you want is just awesome.
Just thank you!
Blessed be you. I was looking for something like this. Thanks!!!
Java?
This software (actually the YUI compressor) needs Java runtime to be installed on the server?
Re: Java?
Yes
When compressing multiple js files, packagecompressor is combining all the js files.
My multiple js files have same function name. So the compressed file is not calling all the function. Any Suggestions?
Hi Chetna,
You need to code your javascript to avoid collisions.
A good pattern to follow is the module pattern. The "Module Pattern" is a generic Javascript pattern that enables a simple class like object hierarchy in Javascript. As long as it's not overused (like creating 100s of objects this way) it's perfect for organizing code in a OOP manner. If you want to read about it in detail, buy a copy of "JavaScript: The Good Parts" by Douglas Crockford - it's a ace book on javascript.
A in-depth resource that I found usefule is, the JavaScript Module Pattern: http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
Hi,
Thank you for the suggestion. But package compressor is combining as well as compressing. Is there any way I can only compress my files and not combine them.
Also I am implementing it on a big old project of my company so cannot change so many js files.
In the clientScript component you will define packages, and the files in each package will be combined. If you have conflicting javascript files, do not put them in the same package and don't register conflicting packages on the same page.
In theory, if you want to only compress, but not combine, you could create many packages, each with only 1 js file. But I think a different tool would be more approriate.
This tool uses a very old Java program to do compression, I would consider it deprecated to be honest.
Hi,
This suggestion would work for the current situation I guess.
Can you suggest any other tool?
Can you also tell me how to register packages from layout file as i don't want to create multiple packages containing single js file in main.php
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.