register jquery.js only one per page

I got this following problem with Yii of loading jquery everytime I use a widget.

For example:

I have a layout named main.php which I tend to register jquery here + fancybox.

<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?>


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

        $cs->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.fancybox-1.3.4.js', CClientScript::POS_HEAD);        

        $cs->registerScriptFile(Yii::app()->baseUrl . '/js/jquery.mousewheel-3.0.4.pack.js', CClientScript::POS_HEAD);


I have a main page which I will use fancybox to load dynamic forms and these forms are built using CActiveForm

page: _simple_form.php

<div class="form">


    $form = $this->beginWidget('CActiveForm', array(

          'id' => 'item-form',

              'enableAjaxValidation' => true,



ok, here I notified that everytime I load this form, jquery.js is listed in firebug:


at this time, jquery won’t recognize fancybox anymore.

$.fancybox.resize() => undefined

Please help!


Try changing widget code to:




But CActiveForm widget is default to Yii.

I have solved this problem by removing Yii jquery package in <yii folder>\web\js\packages.php

Thanks for your help.