optimized-client-script Optimized Client Script Resources

  1. Documentation
  2. Requirements
  3. Description:
  4. Usage:
  5. NOTE:
  6. Known Issues:
  7. Reporting Issue:
  8. Change Log

This extension 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.

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.

Resources

Documentation

Requirements

Yii 1.1.x or above If using the googleComplier API feature then the 'googleComplier' extension needs to be installed and enabled. Download & Install.

Description:

This extension 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.

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.

Usage:

Using this extension is as simple as adding the following code to the application configuration under the components array:

'clientScript' => array(
						'class' => 'ext.clientScript.clientScript',
						'combineScriptFiles' => true, // By default this is set to false, set this to true if you'd like to combine the script files
						'combineCssFiles' => true, // By default this is set to false, set this to true if you'd like to combine the css files
						'googleCompiler' => true, // if you have the googleCompiler extension installed then you can set this to true to compile the script code into an optimized and shorter code.
						'googleCompilerLevel' => 'SIMPLE_OPTIMIZATIONS' // If you enable the above setting then you can specify here the compilation level that can be one of the following:
																		// 'WHITESPACE_ONLY', 'SIMPLE_OPTIMIZATIONS', 'ADVANCED_OPTIMIZATIONS'
),

Then you'd use the regular 'registerScriptFile' & 'registerCssFile' methods as normal and the files will be combined.

NOTE:

This is currently in testing phase so this should not be used on a production environment.

Known Issues:

There are several private class members in the CClientScript class, So merging script blocks and codes and css blocks is impossible. Moreover when using this class css and js blocks might not work properly due to the fact that there are private class members in the class which cannot be overridden. I have filed a bug report to see if those can be set as protected instead.

Other issues may also arise when using this extension so you should test this out on a development application and environment prior using it on a production environment.

Reporting Issue:

Reporting Issues and comments are welcome. For better issue control and management please report any issue to the google project hosting that is listed in the extension overview tab.

Change Log

May 2, 2010
  • Initial release.
2 0
3 followers
1 062 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Tags:
Developed by: Vince.
Created on: May 2, 2010
Last updated: 13 years ago

Downloads

show all