Currently I have an website where each page on the site has a corresponding js file that contains a class (well function) defined in it. Currently when the user navigates to another page (which is just ajax content) I remove the old script tag from the page and add a new script tag for the new page. This is working though I was wondering if there could be any problems with this or better ways to do it? I've been thinking of using an AJAX call (XMLHTTPRequest) to get the new js file then using eval to initiate the new page.
1 Answer 1
What you are doing makes sense because the browser can intelligently cache the js.
Getting the js yourself might prevent the possibility to cache.
<script>would make no difference, right?