Reduce Amount Of Server Requests When Using Ajax

In the application I’am building, I use a lot of AJAX. In the content loaded by AJAX I also use AJAX links and/or forms posted and validated by AJAX. I therefore set the fourth option “processOutput” of renderPartial to true. The negative side-effect of this solution is that with every single request, there are at least two additional requests made for jquery.js and jquery.ba-bbq.js, and in some cases even more request for jquery.yiiactiveform.js, jquery.yiilistview.js and so on.

So, on a single request, there are sometimes up to 5 total requests made. That seems a little too much for me. Is there a way to reduce these requests?

I solved this by using


Yii::app()->clientScript->registerCoreScript('yiiactiveform');

on the views which are initially loaded via a page refresh, and on the views rendered for ajax response i use


Yii::app()->clientscript->scriptMap['*.js'] = false;