How To Check If Script File Already Registered

Hi everyone,

I am using tab with ajax. Every time I open a new page in my tab, the javascript files required is loaded. Then when I open another page on another tab, the javascript required for that page is loaded also.

Now, the problem is that some (not all) javascript needed on the second page is already registered by the first page (e.g the first page has gridview and the second page also, therefore the js required by gridview is already registered by the first page) causing the first page to mulfunction in all javascript related functions (e.g dialog box of the first page)

Is it possible to check whether the javascript is already registered before registering the file ? Please help, thank you

How do you create new page? Using renderPartial?

Yes, I use renderPartial() :




$this->renderPartial('list', compact('model'), false, true);



I think that you have 2 solutions:

  1. Load all javascript for all tabs (if time and size of scripts is acceptable);

  2. Keep in mind what scripts have you loaded, for every renderPartial;

Infact Yii cannot know what scripts have loaded, if you don’t keep track of loads.

Thank you Fabrizio for the reply. As you said, I think I will have to manually check whether the files have been registered or not