With this extension you can transparently reduce page load times by combining and compressing the used Javascript and CSS files.
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.
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:
Total 20 comments
@Rodrigo Coelho
I've published it on the github with your fix: https://github.com/kirs/extendedclientscript
In ExtendedClientScript.php, line 209, replace:
With:
Just started, installed and set the config.
I got: Array to string conversion in [...]/ExtendedClientScript.php on line 209
Hi, 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?
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:
Could I set another server url for generated files like this: http://www.yiiframework.com/doc/api/1.1/CAssetManager#basePath-detail ?
Thank you Nafania it worked like a charm....great work...cheers
Thank u Nafania I shall check this out Tom and let u know how it goes. Cheers
deadmantfa: i posted patch for it at google code, here it is http://code.google.com/p/extendedclientscript/issues/detail?id=1
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
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.
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.
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.
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 '/'.
Thanks! 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]
Hi,
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...
Thanks, Boris
Leave a comment
Please login to leave your comment.