Yii Framework Forum: [EXTENSION] minScript - Yii Framework Forum

Jump to content

  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] minScript combine, minify, compress, cache Rate Topic: ***** 2 Votes

#1 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 26 July 2011 - 07:56 AM

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.

Extension page
0

#2 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 27 July 2011 - 06:20 AM

New version available

1.0.1

  • Replace header_remove function which introduced some issues
  • Client-side cache will expire in 30 minutes now if no number is appended to the URL
  • Optimizations to generateUrl

0

#3 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 27 July 2011 - 01:14 PM

New version available

1.0.2
  • Fixed a bug in generateUrl

0

#4 User is offline   sparkybarkalot 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 12-September 10

Posted 29 July 2011 - 08:46 AM

Thanks for your work on this. I'm having trouble getting this to work. I'm working from the clientScript example, but I'm having some issues:

1) I'm getting the following line generated in my template, but the link just shows roughly two shortish lines of garbage characters when I click on it:

<script type="text/javascript" src="/min/serve/g/jsGroup/0"></script>

2) Looking in /site/protected/runtime/minScript/ and I can see that the "cache" directory has been created but it is empty

I've added the following to the components array in my config file:

'minScript'=>array(
'class'=>'ext.minScript.components.ExtMinScript',
'groupMap'=>array(
'jsGroup'=>array(
'/themes/breathingroom/jvs/jquery-1.6.1.min.js',
'/themes/breathingroom/jvs/tooltip.js',
'/themes/breathingroom/jvs/jquery.cycle.all.js',
'/themes/breathingroom/jvs/jquery.cookie.js',
'/themes/breathingroom/jvs/init.js'
),
),
),

I also added this to my config file (though from the documentation I'm not sure if that's where it should actually go):

// ADDED FOR ExtMinScript extension
'controllerMap'=>array(
'min'=>'ext.minScript.controllers.ExtMinScriptController',
),

I'm using v 1.0.2 of minScript and Yii 1.1.8

Any thoughts or suggestions?

This post has been edited by sparkybarkalot: 29 July 2011 - 09:14 AM

0

#5 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 29 July 2011 - 05:40 PM

New version available

1.0.3

  • Fixed a small bug in generateUrl
  • Throw an exception if a defined file can't be found
  • Change the format of exception messages

0

#6 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 29 July 2011 - 05:50 PM

Hey sparkybarkalot

thanks for reporting this...

1. could you please define "shortish lines of garbage characters", what exact output do you get ?
2. You define the files in the groupMap as paths and not as URL's. You need to define your files as relative paths or absolute paths... In your case use relative paths which means don't have a slash at the beginning of the path: themes/breathingroom/jvs/jquery-1.6.1.min.js
To help you with this, the new version 1.0.3 will throw an exception if a defined file doesn't exist...

Yes, you put the controllerMap in the right place... to get more info on using extensions you can read this: http://www.yiiframew...n/extension.use


View Postsparkybarkalot, on 29 July 2011 - 08:46 AM, said:

Thanks for your work on this. I'm having trouble getting this to work. I'm working from the clientScript example, but I'm having some issues:

1) I'm getting the following line generated in my template, but the link just shows roughly two shortish lines of garbage characters when I click on it:

<script type="text/javascript" src="/min/serve/g/jsGroup/0"></script>

2) Looking in /site/protected/runtime/minScript/ and I can see that the "cache" directory has been created but it is empty

I've added the following to the components array in my config file:

'minScript'=>array(
'class'=>'ext.minScript.components.ExtMinScript',
'groupMap'=>array(
'jsGroup'=>array(
'/themes/breathingroom/jvs/jquery-1.6.1.min.js',
'/themes/breathingroom/jvs/tooltip.js',
'/themes/breathingroom/jvs/jquery.cycle.all.js',
'/themes/breathingroom/jvs/jquery.cookie.js',
'/themes/breathingroom/jvs/init.js'
),
),
),

I also added this to my config file (though from the documentation I'm not sure if that's where it should actually go):

// ADDED FOR ExtMinScript extension
'controllerMap'=>array(
'min'=>'ext.minScript.controllers.ExtMinScriptController',
),

I'm using v 1.0.2 of minScript and Yii 1.1.8

Any thoughts or suggestions?

0

#7 User is offline   sparkybarkalot 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 12-September 10

Posted 29 July 2011 - 08:18 PM

Thanks for the quick reply. I won't be back at the office until Monday, but I'll fix the paths, update the version, and report back. If it's still not working, I'll attach a screenshot of the "garbage characters".
0

#8 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 29 July 2011 - 10:49 PM

New version available

1.0.4
  • Optimized error handling. Most errors will be logged now instead of throwing an exception.

0

#9 User is offline   sparkybarkalot 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 12-September 10

Posted 01 August 2011 - 09:00 AM

TeamTPG,

Thanks so much. It was indeed a path issue as you mention in #2. I removed the leading slash and it started working immediately. Thanks again for your work on this... it's really slick.
0

#10 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 01 August 2011 - 09:40 AM

cool, glad to hear that :)

you're welcome, thanks for the nice words and reporting back :)

View Postsparkybarkalot, on 01 August 2011 - 09:00 AM, said:

TeamTPG,

Thanks so much. It was indeed a path issue as you mention in #2. I removed the leading slash and it started working immediately. Thanks again for your work on this... it's really slick.

0

#11 User is offline   spartans 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 04-August 11

Posted 04 August 2011 - 05:03 AM

hi im new to yii, can neone tell me how to add script files to groups dynamically rather than declaring it in the main conf file.
thanks in advance.
0

#12 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 04 August 2011 - 08:45 AM

hey, if you are talking about the groups in minScript, as of right now you cannot define them dynamically... this might come at a later point in time...

View Postspartans, on 04 August 2011 - 05:03 AM, said:

hi im new to yii, can neone tell me how to add script files to groups dynamically rather than declaring it in the main conf file.
thanks in advance.

0

#13 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 05 August 2011 - 06:57 AM

New version available

1.0.5
  • Code optimizations
  • Improve server-side caching functionality
  • Optimized error handling

0

#14 User is offline   spamec 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 19-February 09

Posted 09 August 2011 - 02:57 AM

Thanks for slick implementation of minify :) One question, is it possible to define scripts to minify, which are registred in extensions by registerScriptFile and registerCssFile?

i.e.

$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$url=$this->baseUrl.'/jquery.bookmark.min.js';
$cs->registerScriptFile($url,CClientScript::POS_HEAD);


0

#15 User is offline   spartans 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 04-August 11

Posted 09 August 2011 - 06:02 AM

View PostTeamTPG, on 04 August 2011 - 08:45 AM, said:

hey, if you are talking about the groups in minScript, as of right now you cannot define them dynamically... this might come at a later point in time...



thank you fr the reply. :rolleyes:
0

#16 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 09 August 2011 - 04:33 PM

yes it is...

what you basically need to do is define the files in the minScript groupMap, for example:

return array(
	...
	'components'=>array(
    	'minScript'=>array(
        	'class'=>'ext.minScript.components.ExtMinScript',
        	'groupMap'=>array(
            	'js'=>array(
                	'path/to/jquery.bookmark.min.js',
                	...
            	),
        	),
    	),
	),    
);


and then before the extension registers the file you will need to generate the scriptMap, like so:
Yii::app()->minScript->generateScriptMap('js');


View Postspamec, on 09 August 2011 - 02:57 AM, said:

Thanks for slick implementation of minify :) One question, is it possible to define scripts to minify, which are registred in extensions by registerScriptFile and registerCssFile?

i.e.

$cs = Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$url=$this->baseUrl.'/jquery.bookmark.min.js';
$cs->registerScriptFile($url,CClientScript::POS_HEAD);



0

#17 User is offline   spamec 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 19-February 09

Posted 10 August 2011 - 03:07 AM

Almost got it, but cant figure out what should be the right path for files, because they're in extension directory. Just before rendering, they're published in assets directory. The assets path is generated like that:

$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendors';
$this->baseUrl = Yii::app()->getAssetManager()->publish($dir);


Summarizing, I dont have path, just filename...
0

#18 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 10 August 2011 - 04:33 AM

thats no problem, just add the files that are in the extensions folder... you dont need to add the files that are published, you dont even need to publish files because they dont need to be in a web accessible folder for minscript to be able to serve them...

so if u have files in extensions folder and those get published, just add following path to groupMap: Yii::getPathOfAlias('ext.blabla.vendors').'/jquery.bookmark.min.js'

View Postspamec, on 10 August 2011 - 03:07 AM, said:

Almost got it, but cant figure out what should be the right path for files, because they're in extension directory. Just before rendering, they're published in assets directory. The assets path is generated like that:

$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'vendors';
$this->baseUrl = Yii::app()->getAssetManager()->publish($dir);


Summarizing, I dont have path, just filename...

0

#19 User is offline   spamec 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 36
  • Joined: 19-February 09

Posted 12 August 2011 - 03:43 AM

Thanks, everything works ::)
0

#20 User is offline   limitless 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 120
  • Joined: 22-July 11

Posted 12 August 2011 - 07:20 AM

glad to hear that, thanks for the feedback

View Postspamec, on 12 August 2011 - 03:43 AM, said:

Thanks, everything works ::)

0

Share this topic:


  • (6 Pages)
  • +
  • 1
  • 2
  • 3
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users