Multiple .js files best practices?

I have quite a bit of JS dealing with AJAX and other functions which I would like to maintain separately. What is the best way to do this?

So far I tried copying _main.js and renaming it, then removing the superfluous code from my new _ajax.js (and duplicate code in main.js) but after a grunt my AJAX requests are not being sent. I’d like my new _ajax.js file to maintain the structure and advantages of the _main.js structure (i.e., being able to specify which pages it’s executed on) if possible.

Is there a better/best way?

I haven’t tried this before, but I would check what Grunt is logging in the console and make sure it’s adding the new _ajax.js file. I would also check the console in Chrome and see if there is an error in the JS somewhere.

Actually, looking at the code that is loaded in _main.js, there are two variables, ExampleSite and UTIL. If the code is still being added into the same file via Grunt, then I assume if you’re still using the same variable names, then anything in _ajax.js is basically being overwritten, since _main.js is probably loaded after.

Brilliant, I just appended every occurrence of those two variables with _ajax and all seems to be working!