Some sugestions to improve Yii

Hi.

Some suggestions of options that i don’t find in Yii. Some of that options can improve the application’s performance, and is been used by various web developers.

I’m learning about it, and after a great search into Yii structure folders, i don’t find a way to put the tag “defer” in the script tag generated by the Yii. In some cases, this tag could substantially reduce the time for loading scripts. Right now i want to defer the load of the CActiveform widget, but i can’t do it.

Other suggestion that i have, and is a question to. I read the tutorial to enable gzip compress to application. But, from what i say, the gzip isn’t working to the assets folder. I tried something with .htacces, but don’t works to css e js files generated in the assets folder.

Well, I apologize if I’m wrong about these 2 things. If already exists a way to resolve the 2 situations, will be nice if someone show me the solutions.

Sorry for my english.

Hugs.

serving static files does not involve running php and Yii so you cannot use same solution for such files as for rendered pages. However you can configure compression on webserver level (in Apache there is mod_deflate) but there must be proper modules installed (if you can administer server confguration you are a winner, if this is shared hosting - there should be everything installed but not always).

Read more about mod_deflate (http://httpd.apache.org/docs/2.0/mod/mod_deflate.html) I am using it with success to compress static files (assets, js, css, and so on).

thanks redguy.

I’ll read about it.

About the “defer” attribute, did you never had this problem? I’m looking for a solution, but until now don’t find anything in Yii that let me insert the attribute in the “script” tag.

never used it… but seems there are two solutions:

  1. place such scripts in plain html (not using clientScript component)

  2. extend CClientScript to handle such scripts (maybe as another script position, like POS_DEFER) and modify rendering procedures…

Or - if you don’t know yet - simply set POS_END which is almost the same behavior.

http://www.yiiframework.com/doc/api/1.1/CClientScript#registerScriptFile-detail

Hii Y!!

Yeah, i’m already using the POS_END, but furthermore, my intention is load the scripts after the parsing of the page. Some scripts i wanna call just when i need of them. This is what the “defer” attribute does.