Extension download:
http://www.yiiframew.../eclientscript/
Note:
I have found another extension created by Vince, but it is too complex and there are many bugs during my usage.
Description:
This extension just extend from {link: CClientScript} using few codes, it will allow you to automatically combine all script files and css files into a single (or several) script or css files. Basically this will reduce the HTTP calls for resources files by merging several resources files into a single (or more) files. It can automatically detect the required list of files, and generate a unique filename hash, so boldly ease of use.
Css Files:
CSS files are merged based on there media attribute, background images with a relative path in file can also be displayed correctly.
Script files:
Script files are merged based on their position, If you use the 'CClientScript::POS_HEAD' you will end up with a single file for all the script files you've used on that page. If you use 'CClientScript::POS_HEAD' and 'CClientScript::POS_END' for example then you'll end up with two files for each page on that request, Since those resources are located in different positions.
Page 1 of 1
[Extension] EClientScript Extended clientscript to automatically merge script and css files
#2
Posted 22 October 2010 - 03:52 PM
Hi! I try use in my project ECLientScript and got:
Fatal error: Maximum execution time of 60 seconds exceeded in D:\usr\...\protected\extensions\EClientScript\EClientScript.php on line 314
Yii version 1.4
all js & css files placed in js/ css/ directories
Fatal error: Maximum execution time of 60 seconds exceeded in D:\usr\...\protected\extensions\EClientScript\EClientScript.php on line 314
Yii version 1.4
all js & css files placed in js/ css/ directories
#3
Posted 25 October 2010 - 09:56 AM
Try to turn off 'optimizeScriptFile', set this options to false.
because the optimization is called via google compiler.
because the optimization is called via google compiler.
#4
Posted 09 November 2010 - 12:38 PM
Fatal error: Maximum execution time of 300 seconds exceeded in \www\protected\extensions\minify\EClientScript.php on line 316
(combineCssFiles=true, all other options=false)
(combineCssFiles=true, all other options=false)
Web-superman. My blog about web development (russian).
#5
Posted 10 November 2010 - 09:26 AM
I also wanted a gzip version of this, so here is my modification.
add the public var to the class
create a new private method
add
in combineCssFiles() and combineScriptFiles() after the line with:
now in your config file you can add
'gzip' => true / false to enable/disable the gzip
Great extension hightman
add the public var to the class
/** * @var boolean if a gzip version of the files should be created */ public $gzip = false;
create a new private method
/**
* GZIP a file
*
* @param $path The file to gzip
* @return boolean
*/
private function gzipFile($path) {
$zp = gzopen($path.'.gz', "w6");
if ($zp) {
gzwrite($zp, file_get_contents($path));
return gzclose($zp);
} else {
return false;
}
}
add
if ($this->gzip) {
$this->gzipFile($fpath);
}
in combineCssFiles() and combineScriptFiles() after the line with:
file_put_contents($fpath, $fileBuffer);
now in your config file you can add
'gzip' => true / false to enable/disable the gzip
Great extension hightman
#6
Posted 08 November 2012 - 02:57 AM
Hi!! Thank you for your great extension.
I try it and it works perfect! But then I use it with optimizeScriptFiles I have some errors in my output javascript files. I tried to use JSMin instead JSMinPlus and in works without errors. Maybe you can change your code or make optimizeScriptFiles to be protected.
Thank you!!
I try it and it works perfect! But then I use it with optimizeScriptFiles I have some errors in my output javascript files. I tried to use JSMin instead JSMinPlus and in works without errors. Maybe you can change your code or make optimizeScriptFiles to be protected.
Thank you!!
#7
Posted 05 December 2012 - 07:02 AM
Nayjest, on 09 November 2010 - 12:38 PM, said:
Fatal error: Maximum execution time of 300 seconds exceeded in \www\protected\extensions\minify\EClientScript.php on line 316
(combineCssFiles=true, all other options=false)
(combineCssFiles=true, all other options=false)
Hey This is worked for me,
changed in
C:\wamp\www\MyProject\protected\config\main.php
find
// application components
'clientScript' => array(
'class' => 'ext.ExtendedClientScript.ExtendedClientScript',
'combineCss' => true,
'compressCss' => false,
'combineJs' => false,
'compressJs' => false,
),
//(combineCssFiles=true, all other options=false)
thank you...
#8
Posted 29 March 2013 - 06:23 AM
Mar 29, 2013
- New version number 1.5
- Compatiable with the 3rd parameter of registerScript and registerScriptFile
- Add support for conditional loading js/css file in IE.
- Prepend the base url of current request when register a script/css file with relative path
Mar 27, 2013 (by Muayyad Alsadi)
- New version number 1.4
- update JSMinPlus, CssMin
- use stronger hash for file names
- consider modification time for calculating hash
- enable all features by default
Dec 06, 2010
- Fixed problem for css files that begin with @charset "xxx", it should be in the first line of file and not repeatly.
- Add support for theme resource files.
- New version number 1.5
- Compatiable with the 3rd parameter of registerScript and registerScriptFile
- Add support for conditional loading js/css file in IE.
- Prepend the base url of current request when register a script/css file with relative path
Mar 27, 2013 (by Muayyad Alsadi)
- New version number 1.4
- update JSMinPlus, CssMin
- use stronger hash for file names
- consider modification time for calculating hash
- enable all features by default
Dec 06, 2010
- Fixed problem for css files that begin with @charset "xxx", it should be in the first line of file and not repeatly.
- Add support for theme resource files.
#9
Posted 29 March 2013 - 06:24 AM
$cs = Yii::app()->clientScript;
// result to: <--[if lt IE 9]><script src="/js/html5.js"></script><![endif]-->
$cs->registerScriptFile('/js/html5.js', CClientScript::POS_HEAD, array('media' => 'lt IE 9'));
// result to: <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="bootstrap/css/ie.css" /><![endif]-->
$cs->registerCssFile('/css/ie.css', 'lte IE 6');
Share this topic:
Page 1 of 1

Help













