Yii Framework Forum: [Extension] EClientScript - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[Extension] EClientScript Extended clientscript to automatically merge script and css files Rate Topic: -----

#1 User is offline   hightman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 23-August 09

Posted 20 October 2010 - 01:30 AM

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.
0

#2 User is offline   Nagash 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 10-September 09

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
0

#3 User is offline   hightman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 23-August 09

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.
0

#4 User is offline   Nayjest 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 85
  • Joined: 05-June 10
  • Location:Ukraine, Kiev

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)
Web-superman. My blog about web development (russian).
0

#5 User is offline   Troto 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 18
  • Joined: 09-March 10

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
/**
 * @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 ^_^
0

#6 User is offline   Xexys 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 30-October 12

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!!
0

#7 User is offline   Mahesh.V 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 3
  • Joined: 09-August 12
  • Location:India,Hyderabad

Posted 05 December 2012 - 07:02 AM

View PostNayjest, 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)

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...
0

#8 User is offline   hightman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 23-August 09

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.
0

#9 User is offline   hightman 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 23-August 09

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');

0

#10 User is offline   muayyad alsadi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-April 11

Posted 13 August 2013 - 08:10 AM

hi, hightman
how can we collaborate on this. I have more suggestions and enhancements

I use github

https://github.com/m...i-EClientScript

and I already took pull requests from other people (like Alexey xt99)

https://github.com/m...d67b52b5d200600
0

#11 User is offline   muayyad alsadi 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 23
  • Joined: 27-April 11

Posted 14 August 2013 - 03:19 AM

I've merged your pull request thank you very much

I shall push any modifications to your repo

https://github.com/h...i-EClientScript
0

Share this topic:


Page 1 of 1
  • 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