jQuery, CSS, and such things

I feel as though I missed something really basic here: if I'm trying to use a jQuery plugin in a page, or attach certain css to a page, where are these files supposed to go? A subfolder for a component that publishes them as assets? Just drop them right into the assets folder and link to them? Create files outside 'protected' for them?

It depends on your needs. If you just want to use the plugin in a single project, you may simply drop the js files under webroot/js. If you want to encapsulate the plugin in terms of a widget so that you can reuse it in different places,  then save the js files together with your widget class file and publish the js files. In any time, you should not handle directly the files under assets directory because theoretically, files under "assets" could be deleted.


if you want to use jquery you can call registerCoreScript() (Yii::app()->clentScript->registerCoreScript('jquery') ) and then all necessary files will be copied to assets folder. Css files you can put in CSS folder in your web root directory and register by registerCssFile() form CClientScript.

Hey, thanks for the responses. Maybe I’ll write a noob guide soon :)

Now, another option besides qwerty's response would be to do something like this:








… and them something like this, in the head of my layout or view…

<?php echo CGoogleApi::init(); ?>


<?php echo CHtml::script(

    CGoogleApi::load('jquery','1.3.2') . "n" .

    CGoogleApi::load('jquery.ajaxqueue.js') . "n" .


); ?>

Correct? And that would let me drop any jQuery plugin into component/js, let's say, and publish it with that component? It's not working for me, which is why I ask.