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

Jump to content

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

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

#21 User is offline   limitless 

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

Posted 23 August 2011 - 02:56 PM

New version available

1.0.6
  • Deactivate CWebLogRoute in Controller
  • Update minify

0

#22 User is offline   limitless 

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

Posted 25 August 2011 - 05:23 PM

New version available

1.0.7
  • Fix error if no log component is set

0

#23 User is offline   limitless 

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

Posted 01 September 2011 - 04:32 AM

New version available

1.0.8
  • Change handling of last modified timestamp for more consistent URLs

0

#24 User is offline   AStron{Z} 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 28-September 11
  • Location:Russia, Moscow

Posted 28 September 2011 - 03:47 AM

Hi, i found bug in FF 7.0, after update FF from 6 to 7 all loading minScript requests aborted every time.
In other browsers all fine. Tested on minScript versions: 1.0.5 and 1.0.8.
Fix it for myself by deleting
header('Content-Length:');
in ExtMinScriptController.
0

#25 User is offline   limitless 

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

Posted 29 September 2011 - 03:32 AM

New version available

1.0.9
  • Update minify
  • Turn on minify logging if Yii debug mode is set

0

#26 User is offline   limitless 

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

Posted 29 September 2011 - 03:58 AM

New version available

1.0.10
  • Fix header handling (fixes a bug with Firefox 7)

0

#27 User is offline   limitless 

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

Posted 29 September 2011 - 03:58 AM

Thank you very much for reporting this...

It is fixed in version 1.0.10

View PostAStron{Z}, on 28 September 2011 - 03:47 AM, said:

Hi, i found bug in FF 7.0, after update FF from 6 to 7 all loading minScript requests aborted every time.
In other browsers all fine. Tested on minScript versions: 1.0.5 and 1.0.8.
Fix it for myself by deleting
header('Content-Length:');
in ExtMinScriptController.

0

#28 User is offline   AStron{Z} 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 28-September 11
  • Location:Russia, Moscow

Posted 01 October 2011 - 07:04 AM

View PostTeamTPG, on 29 September 2011 - 03:58 AM, said:

Thank you very much for reporting this...

It is fixed in version 1.0.10


Thank you for nice extension :)
0

#29 User is offline   Ivica 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 317
  • Joined: 25-May 11

Posted 05 October 2011 - 03:20 AM

Hi,
I am trying to configure your script into my project, so it will combine and minify css files, but I have problem, that url to combined file is urlencoded, so it look like:
<link rel="stylesheet" type="text/css" href="/index.php?r=min/serve&amp;g=css&amp;lm=1317703836" />

Css will be loaded from url above, but I just want to have unencoded urls.

Second, i saw that somebody asked for feature to load groups dynamically. I suppose this feature is not implemented yet, so I will have to implement it by myself. Can you give me short advice how I could load group dynamically, outside config files?

Thanks in advance!
Zurmo: Yii Powered Open Source CRM
zurmo.org
0

#30 User is offline   limitless 

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

Posted 07 October 2011 - 10:46 AM

Hello ivica

the url is automatically encoded since minScript calls Yii's createUrl method... if u need to have decoded urls just use urldecode(Yii::app()->minScript->generateUrl('group').

Yes u are right, it is not implemented as of right now... why do you need to load it dynamically outside of the config file ? it shouldnt be too hard to implement dynamic groupsconfig... you can basically use all the methods that are already in there and just move some things around... the reason why i haven't implemented that feature yet is because it makes things a little more complicated with Yii's clientScript.

View PostIvica, on 05 October 2011 - 03:20 AM, said:

Hi,
I am trying to configure your script into my project, so it will combine and minify css files, but I have problem, that url to combined file is urlencoded, so it look like:
<link rel="stylesheet" type="text/css" href="/index.php?r=min/serve&amp;g=css&amp;lm=1317703836" />

Css will be loaded from url above, but I just want to have unencoded urls.

Second, i saw that somebody asked for feature to load groups dynamically. I suppose this feature is not implemented yet, so I will have to implement it by myself. Can you give me short advice how I could load group dynamically, outside config files?

Thanks in advance!

0

#31 User is offline   Jack80 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-September 11

Posted 07 October 2011 - 06:18 PM

Hi,

I did everything like you said in your documentation.
When I include

<script type="text/javascript" src="<?php echo Yii::app()->minScript->generateUrl('nameOfGroup'); ?>"></script>


in my view file, I see that all js files are merged to one.
But I can't get it done in my controller.
What do I've to do?

I had before:
public function actionSite() {	
 $cs = Yii::app()->getClientScript();
 $cs->registerScriptFile($this->baseUrl.'/jquery.easing.js',CClientScript::POS_END);
...
}


and now I need to place
public function actionSite() {
 Yii::app()->minScript->generateScriptMap('nameOfGroup');
...
}
?

In Yii::app()->minScript I see the scriptMap. But "generateScriptMap" returns null.
Even no file will be placed under the cache directory.

The thing I want is, that all js-files should be merged to one and placed and the end of my file.
Can that be done?

Thank you guys
0

#32 User is offline   limitless 

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

Posted 10 October 2011 - 03:30 AM

Hi Jack80

To add it from your controller u can basically do 2 things:

1.
public function actionSite() {	
 $cs = Yii::app()->getClientScript();
 $cs->registerScriptFile(Yii::app()->minScript->generateUrl('nameOfGroup'),CClientScript::POS_END);
...
}


2.
public function actionSite() {	
  Yii::app()->minScript->generateScriptMap('nameOfGroup');
  $cs = Yii::app()->getClientScript();
  $cs->registerScriptFile($this->baseUrl.'/jquery.easing.js',CClientScript::POS_END);
 ...
 }


you would use the 2nd example to use minscript with files that get added automatically by Yii or other extensions...

in both cases the path to jquery.easing.js needs to be defined in you minScript config.

View PostJack80, on 07 October 2011 - 06:18 PM, said:

Hi,

I did everything like you said in your documentation.
When I include

<script type="text/javascript" src="<?php echo Yii::app()->minScript->generateUrl('nameOfGroup'); ?>"></script>


in my view file, I see that all js files are merged to one.
But I can't get it done in my controller.
What do I've to do?

I had before:
public function actionSite() {	
 $cs = Yii::app()->getClientScript();
 $cs->registerScriptFile($this->baseUrl.'/jquery.easing.js',CClientScript::POS_END);
...
}


and now I need to place
public function actionSite() {
 Yii::app()->minScript->generateScriptMap('nameOfGroup');
...
}
?

In Yii::app()->minScript I see the scriptMap. But "generateScriptMap" returns null.
Even no file will be placed under the cache directory.

The thing I want is, that all js-files should be merged to one and placed and the end of my file.
Can that be done?

Thank you guys

0

#33 User is offline   Jack80 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-September 11

Posted 10 October 2011 - 03:46 AM

Thank you very much! ,
easy :) that worked well.

Just an other short question: Is there a way to keep license comments of files in the minified version?
0

#34 User is offline   limitless 

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

Posted 10 October 2011 - 05:26 AM

my pleasure :)

yes, comments starting with /*! are preserved...

View PostJack80, on 10 October 2011 - 03:46 AM, said:

Thank you very much! ,
easy :) that worked well.

Just an other short question: Is there a way to keep license comments of files in the minified version?

0

#35 User is offline   Jack80 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 5
  • Joined: 27-September 11

Posted 17 October 2011 - 11:06 AM

I still have one question:

How can I cache my files on the client side.
My files always have a Cache-Control: max-age 1y. But I never see, that the files have the response code 304, i always get 200 OK. My files are called like this:

/minScriptController/serve?g=css&lm=1318552431

I've no parameter added to the g-parameter, so normaly it should have a max-age of 1800.
I see Cache-Control: max-age=1800 on the server, but on the client side I see 200 OK max-age=31536000.

What can I do, that all (css- & js-) files will be loaded from the client cache.
All other files, like images, are already cached at client side. (server setting for header-cache)

Thanks in advance!
0

#36 User is offline   Diegovl 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 96
  • Joined: 27-February 11

Posted 18 October 2011 - 09:45 AM

View PostTeamTPG, on 10 October 2011 - 03:30 AM, said:

2.
public function actionSite() {	
  Yii::app()->minScript->generateScriptMap('nameOfGroup');
  $cs = Yii::app()->getClientScript();
  $cs->registerScriptFile($this->baseUrl.'/jquery.easing.js',CClientScript::POS_END);
 ...
 }


you would use the 2nd example to use minscript with files that get added automatically by Yii or other extensions...



Hello, I dont understand what i do to use minescript for files that get added automatically by Yii :)
0

#37 User is offline   limitless 

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

Posted 18 October 2011 - 05:51 PM

Thats intended behaviour... if the browser caches the file for one year it is not going to do another request on the server for a whole year for that file (unless the filename changes, thats where the lm get parameter comes into play). The browser just skips this file and takes it from cache, thats why you only see a 200 OK. You will only get a 304 if the browser actually goes and asks the server if a newer file exists, if not you get the 304 or else the new file (try a page refresh too see this in action). the 200 OK is actually in this case much faster than the 304 because the browser doesn't make a request to the server...

you do have a parameter added to the url, its the LM (last modified) parameter, which is why you see an expiration of 1 year and not only 1800 sec.

So what can you do ? absolutely nothing, because everything already works the way it should and your browser is pulling everything from its cache... if you have firebug you can see that in the NET tab if you want to confirm it, it will tell you how many bytes it pulled from the cache...

View PostJack80, on 17 October 2011 - 11:06 AM, said:

I still have one question:

How can I cache my files on the client side.
My files always have a Cache-Control: max-age 1y. But I never see, that the files have the response code 304, i always get 200 OK. My files are called like this:

/minScriptController/serve?g=css&lm=1318552431

I've no parameter added to the g-parameter, so normaly it should have a max-age of 1800.
I see Cache-Control: max-age=1800 on the server, but on the client side I see 200 OK max-age=31536000.

What can I do, that all (css- & js-) files will be loaded from the client cache.
All other files, like images, are already cached at client side. (server setting for header-cache)

Thanks in advance!

0

#38 User is offline   limitless 

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

Posted 18 October 2011 - 05:58 PM

for example: yii loads jquery in some occasions... in that particular example do this:

add the path to yii's jquery to the minscript config, usually the path is something like this: Yii::getPathOfAlias('system.web.js.source')./jquery.min.js

then call this command before yii loads the jquery file: Yii::app()->minScript->generateScriptMap('nameOfGroupWithJqueryPath');

thats already it... simple and fast :)

View PostDiegovl, on 18 October 2011 - 09:45 AM, said:

Hello, I dont understand what i do to use minescript for files that get added automatically by Yii :)

0

#39 User is offline   limitless 

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

Posted 24 November 2011 - 11:13 AM

New version available

1.0.11
  • Update minify
  • Adjust method/property visibility
  • Adjust error messages and logging parameters

0

#40 User is offline   Embedder 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 23-November 10
  • Location:Ukraine

Posted 03 December 2011 - 08:51 AM

Hi TeamTPG,

I would like to ask one question, since have a small problem with your extension.

For example, I have a groupMap:
'jsExtGroup' => array(
    'js/script.js',
    'js/grayscale.js',
    'js/raphael.js',
    'js/man.js',
    'js/woman.js'
),


When doing this:
Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl . '/js/man.js');
Yii::app()->minScript->generateScriptMap();
all of the scripts listed in the group are registered to new min-file.

This is normal behavior? (–°an I get in the final packaged file code of only those scripts that are registered through clientScript?)

Thanks.
0

Share this topic:


  • (7 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 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