Add Script / Register Script And Css

Hi

I’m using google’s jquery and using gvchart.I include it in site.layout.main file

is there any way to store this when the first time it loads and after that it takes all that stuff from that folder/file ?

i also used


Yii::app()->getAssetManager->publish('www.google.com/jsapi'); 

bt it gives error.





$baseUrl = Yii::app()->baseUrl;

  $cs = Yii::app()->getClientScript();

  $cs->registerScriptFile('www.google.com/jsapi');

  $cs->registerCoreScript('jquery');

  $cs->registerScriptFile($baseUrl.'/css/jquery.gvChart-1.0.1.min.js');

  $cs->registerScriptFile($baseUrl.'/css/pbs.init.js');

  $cs->registerCssFile($baseUrl.'/css/jquery.css');




if u have any link pls send

5571

ggg.png

thank u :D

JB

If you want to serve the file from your site, just download the relevant file, put it into a web accessible directory (such as www/js) and serve it as you would any local content.

Your user will still re-download the relevant files if they hit refresh, but it will be from your server rather than Google’s, which may or may not be beneficial.

thanx… it helped me so …

ok the next thing i want to ask is what is assetsManager->publish() ?? how to use it in our application ?

because it copies the main files or not.

It copies scripts from a protected location to a web accessible one. It’s intended to allow people to package up server and client scripts in one place rather than spread them across protected and web directories.

Did you already have a look at http://www.yiiframework.com/wiki/148/understanding-assets/ and http://www.yiiframework.com/wiki/311/assetmanager-clearing-browser-s-cache-on-site-update/?

Those articles helped me a lot to understand and use the AssetManager.

thank you @keith and Jonas …it Helps a lot