2017 © Pedro Peláez
 

yii-extension clientscript

JS/CSS compressor for the Yii framework

image

yiicod/clientscript

JS/CSS compressor for the Yii framework

  • Monday, February 29, 2016
  • by lexxorlov
  • Repository
  • 0 Watchers
  • 0 Stars
  • 260 Installations
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 4 % Grown

The README.md

Requirements

Yii 1.4.x or above, (*1)

Description (This is fork from EClientScript with fixes problem in CssMin):

EClientScript (an extension for Yii's CClientScript), (*2)

This is an optimizing client script manager for Yii framework, that can minify and combine CSS/JS files., (*3)

It will automatically detects changes in file content (based on modification time) and generates a unique file name accordingly., (*4)

This will reduce the HTTP calls for resources files by merging several resources filesinto a single (or more) files., (*5)

The source code is hosted under bitbucket:, (*6)

https://bitbucket.org/yiicod/clientscript.git, (*7)

Css Files:

CSS files are merged based on there media attribute, background images with a relative path in file can also be displayed correctly., (*8)

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., (*9)

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, becuase those resources are located in different positions., (*10)

File optmization

CssMin used to optimize merged css file. You can set property 'optmizeCssFiles' of the component to enable this feature. JSMinPlus used to optimize merged script file. You can set property 'optmizeScriptFiles' of the component to enable this feature., (*11)

Usage:

  1. Using this extension is as simple as adding the following code to the application configuration under the components array:
  'clientScript' => array(
    'class' => 'application.vendors.yii-EClientScript.EClientScript',
    'combineScriptFiles' => !YII_DEBUG, // By default this is set to true, set this to true if you'd like to combine the script files
    'combineCssFiles' => !YII_DEBUG, // By default this is set to true, set this to true if you'd like to combine the css files
    'optimizeScriptFiles' => !YII_DEBUG,    // @since: 1.1
    'optimizeCssFiles' => !YII_DEBUG, // @since: 1.1
    'optimizeInlineScript' => false, // @since: 1.6, This may case response slower
    'optimizeInlineCss' => false, // @since: 1.6, This may case response slower
  ),

Then you can use the regular 'registerScriptFile' & 'registerCssFile' methods as normal and the files will be combined or optimized automatically., (*12)

  1. Using to conditional loading js/css file for IE browser, you just need to specify the media property.
$cs = Yii::app()->clientScript;

// result to: 
$cs->registerScriptFile('/js/html5.js', CClientScript::POS_HEAD, array('media' => 'lt IE 9'));

// result to: 
$cs->registerCssFile('/css/ie.css', 'lte IE 6');

Known Issues:

When some resource files can not be merged and they are strictly dependent on loading order, then may have some problems., (*13)

The Versions

29/02 2016

dev-master

9999999-dev

JS/CSS compressor for the Yii framework

  Sources   Download

New BSD License

The Requires

  • natxet/cssmin 3.0.*

 

29/02 2016

2.0.0

2.0.0.0

JS/CSS compressor for the Yii framework

  Sources   Download

New BSD License

The Requires

  • natxet/cssmin 3.0.*

 

21/11 2015

1.0.2

1.0.2.0

JS/CSS compressor for the Yii framework

  Sources   Download

New BSD License

The Requires

  • natxet/cssmin 3.0.*

 

05/06 2015

1.0.1

1.0.1.0

  Sources   Download

New BSD License

The Requires

  • natxet/cssmin 3.0.*

 

04/06 2015

1.0.0

1.0.0.0

  Sources   Download

New BSD License

The Requires

  • natxet/cssmin 3.0.*