Yii 1.1: minscript

combine, minify, compress, cache

Development of minScript has been DISCONTINUED. There will be no future updates, bug fixes or support.

minScript is a Yii Framework extension which extends clientScript to automatically combine, minify and compress files. The files are served with optimal client cache headers which dramatically improves the web application performance and eases the load on web servers.

Please visit the extension's wiki page for a full documentation on minScript.

You may find more help and information in the minScript forum topic.

To report a problem or see open issues visit the extension's issues page.

Total 20 comments

#18575 report it
atrandafir at 2014/11/19 11:39pm
@Lo3ty minscript with ckeditor

Hello Lo3ty,

I havent used the EditMe extension but I did used ckeditor on a project using minScript.

The issue with ckeditor is the following:

  • MinScript compresses the files to let's say, the path:
<link rel="stylesheet" type="text/css" href="/min/serve?[...]" />
  • ckeditor loads separately some extra javascript files from it's base folder, let's say for example /js/ckeditor/

  • so when you activate minscript, ckeditor looks for its extra javascripts in the wrong place, in /min/serve, instead of /js/ckeditor

So, using ckeditor standalone without editme extension and with minScript, the solution would be to add this line somewhere in your main layout:

    Yii::app()->clientScript->registerScript('ck',"window.CKEDITOR_BASEPATH = '". Yii::app()->request->baseUrl."/js/ckeditor/';", CClientScript::POS_HEAD)

That way you tell ckeditor where to look for its scripts.

Since EditMe extension registers its own assets you might need a different approach.

     * Initialize the editMe widget.
    public function init() {
        $this -> _ckeExtensionPath = dirname(dirname(__FILE__)) . '/vendors/CKEditor';
        // Start the publishing process if it has not been executed on the current page already
        if (empty(self::$_ckeAssetUrl)) {
            $excludeFiles = Yii::app() -> assetManager -> excludeFiles;
            array_push(Yii::app() -> assetManager -> excludeFiles, 'CHANGES.md', 'README.md', 'samples');
            self::$_ckeAssetUrl = Yii::app() -> assetManager -> publish($this -> _ckeExtensionPath);
            Yii::app() -> assetManager -> excludeFiles = $excludeFiles;
            $ckeAssetPath = str_replace(Yii::app() -> assetManager -> baseUrl, Yii::app() -> assetManager -> basePath, self::$_ckeAssetUrl);
            if (@is_file($ckeAssetPath . '/editMe.' . md5(self::$_ckeAssetUrl) . '.min.js') === false) {
                $scriptContents[] = 'var CKEDITOR_BASEPATH=' . CJavaScript::encode(self::$_ckeAssetUrl . '/') . ';';
                $scriptContents[] = @file_get_contents($ckeAssetPath . '/ckeditor.js');
                $scriptContents[] = @file_get_contents($ckeAssetPath . '/adapters/jquery.js');
                @file_put_contents($ckeAssetPath . '/editMe.' . md5(self::$_ckeAssetUrl) . '.min.js', implode("\n", $scriptContents), LOCK_EX);

I can see it has its own way of publishing the assets, generating a special script file where it even adds the line I'm telling you to add with a CKEDITOR_BASEPATH.

All I can say is that now you know what ckeditor needs, and you can debug the generated scripts to see if they point to a good place, and maybe do some tweaks to the extension's init method. Mozilla Firebug/Chrome console can help you with javascript errors debugging.

In the last place, you could move ckeditor files from extension vendor dir and place it somewhere up such as /js/ckeditor and change all the lines that load it to avoid publishing assets and instead load it with direct clientScript commands, like for example:

<?php Yii::app()->clientScript->registerScriptFile('/js/ckeditor/ckeditor.js', CClientScript::POS_END); ?>

Anyways if you like the extension approach I think you can modify it and adjust the init method until you get a decent solution.

#18573 report it
Lo3ty at 2014/11/19 04:37pm
minscript + editMe

Did someone managed to use minscript together with editMe Extension? (CKE Editor)

If I use both on every page containing an CKE Editor instance I get the following js error: CKEDITOR is not defined

It seems to be that minscript is somehow ignoring the CKE js files so that it cant be initialized. :(

Don't know what to do. Can someone help me?

#17530 report it
ehochedez at 2014/06/29 11:12am
Combine minScript and URL and showScriptName=false


I have set up the minScript extension that works well and I just started the URL rewriting. When using the option 'showScriptName'=>false, my websites cannot find the script and css minimized by minScript anymore. Both my URL rewriting and the minScript extension seem to work fine independently but I can't get them to work together, can't figure out why.

The action ExtMinScriptController > actionServe is usually called but not in the case of the 2 working toghether. Here is the interesting part of my my config file :

                '<action:(searchUser|myProfile|myPictures|register|resetPassword|logout)>' => 'user/<action>',
                '<action:(index|contact)>' => 'site/<action>',
                '<action:(inbox)>' => 'message/<action>',

Anyone has the same problem ?

#17377 report it
atrandafir at 2014/05/30 03:23am
SEO suggestion for error 500


I have noticed minScript gives a error 500 if the files used for a specific group are no longer available.

That's somehow bad for SEO because your site is giving a server error 500.

I think it should give a 404 not found error instead. Or maybe, keep the compressed group stored on disk until you manually remove assets?

Regards, Alex.

#15759 report it
darioo at 2013/12/14 04:45pm

This is great extension, I love it (Y) :D

#15423 report it
Nacesprin at 2013/11/08 06:51am

This script is what I was looking for!! It works fine!!

#15255 report it
limitless at 2013/10/21 12:08pm
Re: Using minScript with bootstrap extension

Hey Scott Gardner

Thank you for reporting this. I replied to your request in the minScript forum topic and hope we can find a solution to this since multiple people have reported similar issues.

#14351 report it
Scott Gardner at 2013/08/05 08:13pm
Using minScript with bootstrap extension

I am using the bootstrap extension. When I add the minScript extension, TbButtonColumn buttons are not displayed. Any ideas? Thank you

#13333 report it
limitless at 2013/05/22 01:07pm
Re: Needs a lot of work

Hey notsoluckycharm

if i understand you correctly you are suggesting that minScript should create the combined, minified and compressed files instead of serving the content out directly. The content is served directly for some good reasons, one of them being that this allows to send specific headers directly without having to change the web server configuration.

I'm sorry to hear that it breaks your scripts. Most of the time this is a problem of how the scripts react to being minified and combined and not all scripts play well with that. In minScript version 2.2 you can exclude certain files from being processed, this might help.

#13332 report it
limitless at 2013/05/22 12:55pm
Re: Application slowdown after configure an extension

Hey karmraj

The slowdowns you are reporting are most likely caused by another extension which constantly publishes files and therefore forces minScript to update itself all the time. Unfortunately there is not more information but try looking in that direction.

Also, "optionname" and "optionvalue" are placeholders which can be replaced by properties as described here.

#13331 report it
limitless at 2013/05/22 12:49pm
Re: Problem serving the content

Hey olemara

First of all, thank you for the praise.

This looks like a problem with your "CUrlManager" configuration. Is the property "urlFormat" set to "get" or to "path"? Try setting it to "get".

Also i think some information got stripped out of your comment (URL) which makes it a bit harder to debug this.

#13330 report it
limitless at 2013/05/22 12:42pm
Re: Using minScript with yii-debug-toolbar?

Hey atrandafir

Since version 2.2 you can exclude certain files from being processed. Have a look at the property ExtMinScript::$minScriptUrlMap

#13329 report it
limitless at 2013/05/22 12:39pm
Re: Keeps telling me there are unexpected token ! and some functions are not defined....

Hey jiaming

I tried the configuration you provided and it works flawlessly for me. Are you using the latest version of minScript (2.2)?

#12600 report it
notsoluckycharm at 2013/03/31 05:14pm
Needs a lot of work

Wish it would integrate and publish assets passed to it using absolute urls instead of making itself as an endpoint.

It also breaks half my scripts ( require.js ) ... moving on to the next extensions.

#12588 report it
karmraj at 2013/03/30 07:17am
Application slowdown after configure an extension

My Application is under development. I have read about this extension from community. Today i have configure this extension. It's working perfectly but it takes more time then before it takes to load a page.

I have make following change in configuration file. And one more problem is that, whatever steps i have follow to configure this extension from this link : bitbucket.org/TeamTPG/minscript. i got an error as "Extoptionvalue" is not define so when i had commented follwing optionname line its working.



so let me know, is there any problem in my configuration or i had made any mistakes.

Thanks, Karmraj Zala

#12147 report it
olemara at 2013/03/01 04:17am
Problem serving the content

Hi there,

and thank you for what seems to be a great extension. I am new to the minifying process so there may be holes in my knowledge here. I have the newest Yii version, minify 2.1 installed, and the latest version from your homepage. The folders are created in the runtime directory, but I get this message in the php log file:

[Fri Mar 01 10:00:44 2013] [error] [client] File does not exist: /var/www/min/serve, referer: http://localhost:5555/

So I can not serve the file. Using the URL builder i get URL's like this:

which works. How can I buypass this problem?


#11753 report it
atrandafir at 2013/02/01 10:14am
Using minScript with yii-debug-toolbar?


I am using yii-debug-toolbar on my development machine and minScript does process also the javascript/css coming from yii-debug-toolbar, and that makes the page a little bit slower.

Is there any way I can tell minScript to exclude it?


#11206 report it
andyhot at 2012/12/27 02:56pm
Coffeescript + sass + less

minscript works fine for me, so, thx!

I've even got a fork up at https://bitbucket.org/andyhot/minscript that adds support for coffeescript, sass, less (basically by augmenting ExtMinScriptSource)

#10936 report it
jiaming at 2012/12/05 01:12am
Keeps telling me there are unexpected token ! and some functions are not defined....

Keeps telling me there are unexpected token ! and some functions are not defined....

Looks like the javascript integration isn't going well...

Here is my setup, any problems?


THank you!

#10590 report it
limitless at 2012/11/06 06:31am
Re: Issue with wysiwyg loading

Hey Revelis Luc Bonnin

I tried to reproduce this with RedactorJS but it worked flawlessly in my setup.

If there's still a problem please report an issue here with more details of your setup: https://bitbucket.org/TeamTPG/minscript/issues?status=new&status=open

Leave a comment

Please to leave your comment.

Create extension