All parameters can be set in your main.php config. No need for altering your code, just set and forget.
Needs Yii 1.0.4/1.1.x or greater, and for compression JSMin and CSSTidy.
- Yii 1.0.4/1.1.x or above
Since version 0.9
- Extract the zip file under 'proctected/extensions'
- Add the following to your 'config/main.php':
// application components 'components'=>array( .... 'clientScript'=>array( 'class'=>'ext.ExtendedClientScript.ExtendedClientScript', 'combineCss'=>true, 'compressCss'=>true, 'combineJs'=>true, 'compressJs'=>true, ),
And you're set!
For more options see the comments in the file. To mention a few:
- excludeFiles: array with files not to be combined/compressed. Handy for some rarely used JS/CSS files.
- autoRefresh: If false, no check on filemtime() to speed up a bit more. Useful in production.
Change Log ¶
August 30, 2011: 0.9.0 ¶
- New version, using CssMin and JsMin (included). Several improvements of Sam included.
August 23, 2011: 0.4.1 ¶
- Automatic exclusion of remote files (JS as well as CSS), so you can use your CDN of choice. Thanks Kir!
- By popular demand: removal of DIRECTORY_SEPARATOR, changed to '/'
March 12, 2009 ¶
- Additional test to prevent E_ALL errors.
March 11, 2009 ¶
- Initial release.
CSS file handling need to be improved
The option "excludeFiles" does only work for JS files. CSS files getting combined/compressed even if listed in the option "excludeFiles".
Another improvement would be to exclude all files where the path points to a CDN.
csstidy too old
seems that csstidy is too old for php 5.3 :(
"Non-static method csstidy::is_important() should not be called statically, assuming $this from incompatible context" .. don't want to start debugging as it ends up with 6 hours and no result :)
Trying to find a good alternative...
DIRECTORY_SEPARATOR is - as the name says a directory separator, not a url separator. So it works well with linux and mac because the folder separator in urls matches the directory separator.
As windows uses the backslash \ creating a url with the constant DIRECTORY_SEPARATOR can't work anymore on windows virtual hosts.
So there definitely has to be a "/" instead of the constant DIRECTORY_SEPARATOR.
Updated extension code
Same problem with DIRECTORY_SEPARATOR.
I have the same issue Boris did.
For me in line 221 does not make sense use DIRECTORY_SEPARATOR because this a URL separator and not a file separator.
You said: "It is also used in several other places in this extension".
This is just coincidence.
In my Windows XP DIRECTORY_SEPARATOR is '\' and in your tests maybe is LINUX. And linux maybe is '/' separator, just like URL separator which is '/'.
DIRECTORY_SEPARATOR is a predefined PHP constant, so that can't (shoudn't) be the real issue. It is also used in several other places in this extension.
BTW: Might be better to use the forum thread for this: [url=http://www.yiiframework.com/forum/index.php/topic,1091.0.html]forum discussion[/url]
Great job, is this a bug?
it works fine for me. Great idea, no need to reinvent the wheel now ;-)
But can you please check the line 221 in the current revision of ExtendedClientScript
I think DIRECTORY_SEPARATOR is wrong, i did not work for me, it worked as i changed it to "/". How come? Idea?
Otherwise i got errors that resource could not be found...
DIRECTORY_SEPARATOR BUG AND RECOMMENDED
In the 221 line, you can not use DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR used in the URL is not correct, I agree this is a bug. In addition, can you turn the associated documents to be re-released, such as the pictures to use relative paths inside css file? I think this is necessary, css files are mapped to another file, the directory path has changed, the picture of the paths must be properly re-mapping.This is also can be done.
DIRECTORY_SEPARATOR not needed
DIRECTORY_SEPARATOR is not needed. As long as you use forward slashes (/) everywhere everything will work as intended.
All *nix systems use forward slashes (/) while windows use back slashes (). The good news is that Windows converts forward slashes (/) into back slashes () hence why you should only use forward slashes (/). It's been like this for ages and that's how i do it.
Facing a problem
Hi first of all thank you for this extension i have been using it for quite sometime now....just one problem...now whenever i use a widget from yii the images do not load when the compression is on...if i take the compression off it works fine...i checked the css which is calling the images and they are fine but once the compression happens the css file gets moved and so the path in the css does not work... how do i make it work..kindly help
Re: Facing a problem
deadmantfa: i posted patch for it at google code, here it is http://code.google.com/p/extendedclientscript/issues/detail?id=1
thank you Nafania
Thank u Nafania I shall check this out Tom and let u know how it goes. Cheers
Thank you Nafania it worked like a charm....great work...cheers
Another server host
Could I set another server url for generated files like this: http://www.yiiframework.com/doc/api/1.1/CAssetManager#basePath-detail ?
I propose you to enhance some functionality of excluding css and js files:
And renderJs function:
After this enhances I can do this in my config:
Thank you for the extension.
Do you have an idea what can cause this error:
It appears only if
For a quick fix I added
to config file.
Is it expected behavior?
Array to string conversion
Just started, installed and set the config.
I got: Array to string conversion in [...]/ExtendedClientScript.php on line 209
@Nathan - Re: Array to string conversion
In ExtendedClientScript.php, line 209, replace:
I've published it on the github with your fix: https://github.com/kirs/extendedclientscript
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.