Hi, I want to modify Yii’s behavior of loading jquery related files from its internal asset files to CDN hosted ones. I noticed that doing something like the following in the config file achieves this:
'scriptMap' => array(
'jquery.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js',
'jquery.min.js' => '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js',
'jquery-ui.min.js' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js',
'jquery-ui.css' => '//ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/black-tie/jquery-ui.css',
),
'packages' => array(
'jquery' => array(
'baseUrl' => '//ajax.googleapis.com/ajax/libs/jquery/',
'js' => array('1.11.1/jquery.min.js'),
),
'jquery.ui' => array(
'baseUrl' => '//ajax.googleapis.com/ajax/libs/jqueryui/',
'js' => array('1.11.2/jquery-ui.min.js'),
'css' => array('1.11.2/themes/black-tie/jquery-ui.css'),
),
)
Notice how the scripts are repeated? I may be doing this wrong but when using jqueryui through clientscript::registerPackage(“jquery.ui”), I could only get it to load the scriptmap jqueryui CSS file if I have a jquery.ui entry as well in the packages key. Now removing the scriptmap array works fine and is actually how I have the project I’m working on right now set up, but that also means I have to individually set up the script and CSS files for each jquery yii widget I plan to use through the widgetFactory. Adding the scriptmap entries allows me to tell yii to load any of the defined files/strings from google.
I was just wondering if this was the right way to globally have jquery and jqueryui files be loaded from somewhere else (whether it be from manually registering a package, or from a widget call that uses jquery)