Instead of using the HeadHTML webpart, I'd recommend going with the Javascript webpart on your templates. As Joshua mentioned, it gives you more flexibility on placement in the DOM and with loading the js itself, and it seems to play nicer with fetching js from the custom dir.
Don't use the tilde (~) path, which I've found can be janky. The Javascript webpart will enter a path like this -- Custom/myJsFile.min.js
without the leading tilde and slash. Dots in the file name are OK.
Another handy feature of the Javascript webpart is that you can add script directly to the template, which is useful for init js. But be careful about loading a file and adding an init in a single Javascript webpart. I've run into problems that way and usually use a separate webpart for each.
As for the files themselves, instead of copying your js file to the custom dir on the server, go to Apps --> Dev --> Javascript files. Then, create a new one and copy-paste the js into the popup or upload the file. If you upload, make sure .js files are allowed. You can check at Settings --> System --> Files --> Security --> Upload extensions.
One more gotcha I've discovered, syncing doesn't work for the js files, at least in our environment. So if you're staging content, be sure the js gets to the custom dir on your production servers.