You can also do this by loading a view containing your JavaScript.
I am currently loading JavaScript from the view at the end of the displayed page. Since it has a PHP file with html <script> , you can use helper URL functions like site_url() to create the URLs needed for each function.
An example may contain:
<script> $.ajax{ url : "<?=site_url("controller/function")?>", data : {a:1,b:2}, } </script>
This will give you codes created using CodeIgniter for your JavaScript. You can even pass variables to the view for more control over js.
source share