I do not think it is possible to unload a js file, to dynamically load one, try1. testjs.html
<div onmouseover="loadjs()">move this area to load js file, click on "call hello" to check </div>
<input type="button" value="unload js" onclick="hellojs.src='';">
<input type="button" value="call hello" onclick="hello()"><script language="javascript" id="hellojs" src=""></script>
<script language="javascript">
var bloaded = false;
function loadjs()
{
 if (!bloaded)
 {
  hellojs.src='test.js';
bloaded = true;
 }
}
</script>
2. test.js:
function hello()
{
  alert("hello");
}