[eluser]Twisted1919[/eluser]
The simplest and cleanest solution i think would be like so :
Create a controller that will serve your javascript files only, something like assets .
Then, depending on the param passed to this controller, load a view with php + js code and put the javascript headers so that the browser will see it like javascript .
In the head of your templates, you will have something like :
<s_cript src="http://mydomain.com/assets/my-js-view-file-that-has-php-within"></s_cript>
The assets controller will load the view you specify and you're good to go .
In this way, in your view you can specify and CI code and it will work .
This is just an idea that worth trying.