I´m having troubles with AJAX navigation, the problem is that the javascript files loaded remains in the browser after the new content is loaded even they aren't in the DOM anymore, and they appears as VM files in the browser console and execute the code inside it. I don't want that happen because the javascript file it supposed to be replaced when the new content comes via AJAX.
My DOM structure is like this:
<body>
<header></header>
<main id="contentToBeReplaced">
<p>New content with its own js</p>
<script>
var script = "js/new.js";
$.getScript(script);
</script>
</main>
<footer></footer>
<script src="js/main.js"></script>
</body>
Every time a page is loaded with its own javascript file appears a new VM file and keeps all the olders, and thats a problem:

So, whats the problem and how can I fix this? I need to prevent duplicated files and remove the js file when a new its loaded.