Stop load jquery library from assets folder in Yii

I had problem in my app that made it slow , after checked firebug

I noted that jquery-ui loaded twice first from google.com and second from assets folder ("232kb") .

How to force it to load from google.com without assets version ?

View content " JavaScript to call Ajax function ":


	....

 		$(".third,#second-next,#fourth-pr").click(function () {

    	

                	$.ajax({

                    	url: '<?php echo Yii::app()->createUrl('site/CallScientificForm',array('language'=>language())); ?>',

                    	type: 'GET',

                    	dataType: 'html',

                    	beforeSend: function () {

                        	$("#loading").show();

                    	},

                    	success: function (data, textStatus, xhr) {

                        	$("#hr3").css("background", "#51a351");

                        	$("*").removeClass("active");

                        	$(".third").addClass("active");

                        	$("#firstContent ,#secondContent,#thirdContent,#fourthContent").fadeOut(2000);

                        	$("#thirdContent").html(data);

                        	$("#thirdContent").fadeIn(2000);

                        	$("#loading").hide();

                    	},

                    	error: function (xhr, textStatus, errorThrown) {

                        	$('#' + id + ' .contentarea').html(textStatus);

                    	},

                    	complete: function() {

                        	$(this).data('requestRunning', false);

                    	}

                	});

    	

            	});

	...

Controller:


   ...

  	public function actionCallScientificForm()

    	{

        	$scienceModel = new MembershipScientific();

        	$view= $this->renderPartial('_ScientificForm', array('scienceModel' => $scienceModel, 'language' => language()), false, true);

        	echo $view;

        	Yii::app()->end();

    	}

	..

Main config:


 'clientScript'=>array(

            	'packages'=>array(

                	'jquery'=>array(

                    	'baseUrl'=>'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/',

                    	'js'=>array('jquery.js'),

                    	'coreScriptPosition'=>CClientScript::POS_END

                	),

                	'jqueryMin'=>array(

                    	'baseUrl'=>'http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/',

                    	'js'=>array('jquery.min.js'),

                    	'coreScriptPosition'=>CClientScript::POS_END

                	),

                	'jquery-ui'=>array(

                    	'baseUrl'=>'https://code.jquery.com/ui/1.11.1/jquery-ui.min.js',

                    	'js'=>array('jquery-ui.min.js'),

                    	'depends'=>array('jquery'),

                    	'coreScriptPosition'=>CClientScript::POS_END

                	)

            	),

        	),

And I called it in target view like this :


  ....

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

  

	$cs->registerCoreScript('jquery');

	$cs->registerCoreScript('jquery-ui');

	....



Thanks in advance

1 Like

It’s well known bug and you can find plenty of solutions.

I use ‘scriptFile’ option in my widgets so instead of adding new asset with the js it uses the same one I registered for the whole site.

Thanks Bizely , I traid scriptFile , and


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

    	$cs->scriptMap=array(

        	'jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js',

        	'jquery.min.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js',

        	'jquery-ui.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js',

        	'jquery-ui.min.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.8.7/jquery-ui.min.js'

    	);



But same results in firebug ?!

1 Like

Problem was solved by disable js , and recall js files in layout .


...

'components' => array(     'clientScript' => array(          // disable default yii scripts         'scriptMap' => array(             'jquery.js'     => false,             'jquery.min.js' => false,             'core.css'      => false,             'styles.css'    => false,             'pager.css'     => false,             'default.css'   => false,         ),     ),

....