Well there are two simple ways .
First Method
Creates a folder assets in ci main folder which should contain 3 folders css , images and scripts
Now go to config/constants.php and define a constant there let say JS
define('JS','http://localhost.com/myapp/assets/scripts');
And now in your view file just write
<script type="text/javascript" src="<?php echo JS?>/myfile.js"></script>
It will be loaded.
The other method is that go to config.config.php
Change base url
$config['base_url'] = 'http://localhost/task/';
$config['js'] = 'assets/js';
And now in controller
$data['js'] = $this->config->item('base_url').$this->config->item('js');
And now in view
<script type="text/javascript" src="<?php echo $js?>/myfile.js"></script>