Yii 1.1: mt-clientscript

Combines all js files and css files and puts js files on the HTML bottom
6 followers

This extension saves a lot of bytes and GET-requests!

All CSS files and all JS files get combined (this saves the browser from making unnecessary requests to the server).

Then these files get compressed (Google closure compiler for JS and Yahoo's YUI Compressor for CSS). This squeezes out the last possible byte by removing comments, whitespaces, renaming internal variables etc.

At last the JS file is put at the bottom of the page. This way the site is rendered and displayed, before the browser once again contacts the server to get the javascript file

Requirements

Yii 1.1 or above

Usage

Just add these lines into your configuration file below under "components"

'clientScript' =>array(
    'class' => 'ext.mtClientScript.mtClientScript',
       'excludeFiles' => array('/js/jwysiwyg/jquery.wysiwyg.css', [...]),
       'javaPath' => '/usr/bin/java',
       'yuicPath' => '/home/peter/tools/yuicompressor-2.4.2.jar',
       'closurePath' => '/home/peter/tools/closure.jar',
 ),

Resources

Get this extension strictly from GIT. So you also can improve it and send a pull request - and I'll merge it.

https://github.com/mintao/yii-ext-mtClientScript

Total 2 comments

#2460 report it
logity at 2011/01/05 06:35pm
problems with jquery jquery.ui including

perhaps you should do $this->scriptFiles[self::POS_END] = array_merge( $this->scriptFiles[$pos], $this->scriptFiles[self::POS_END] ); b/c forexaple I include jquiry.ui.js in POS_END in you variant the order will be jquiry.ui.js jquery.js

Also I didn't find how you exclude js files, only css

#2459 report it
logity at 2011/01/05 06:02pm
problems with jquery jquery.ui including

seems you have mistake 'closurePath' => '/home/peter/tools/closure.jar', (should be compiler.jar)

I always get error JQuery is not defined, just like jquery.js is included after all other scripts.

Leave a comment

Please to leave your comment.

Create extension
Downloads
No downloadable files yet
  • Yii Version: 1.1
  • License: Other Open Source License
  • Developed by: mintao
  • Category: Others
  • Votes: +3 / -1
  • Downloaded: 0 times
  • Created on: Dec 23, 2010
  • Last updated: never
  • Tags: css, js, javascript, stylesheet, speed