[eluser]CroNiX[/eluser]
Sure you can, just use php to output the js vars in the head of your document before loading your external js scripts.
In your template, in the head section:
Code:
<head>
<skript type="text/javascript">
<?php echo $js_vars; ?>
</skript>
<?php // load your other js files below this ?>
</head>
In your controller (or better yet, MY_Controller):
Code:
$data['js_vars'] = 'var base_url = "<?php echo base_url(); ?>";';
Then load your view and pass $data to it.
Now as long as your other js scripts get loaded AFTER where you echo the $js_vars in the <head>, you can use base_url within them and it will be dynamic. If you change $config['base_url'] in CI, the js will change automatically.
If I had to remember to change all of that hardcoded crap when I put it on a different server I think I'd shoot myself. This is much simpler and you only have 1 place you need to update base_url, which is how code should be.