I have a module that is dependant on a couple of Javascript files.
How can I load these Javascript files on the front end when my module is called?
They are quite large so I cannot simply use an inline <script></script>
I think you're looking for this page in the EE Developer docs.
Basically, if you only need the JS in the Control Panel (so not on the front-end of the site), put your JS files in the /your_addon_package/javascript/ folder and then use $this->EE->cp->load_package_js('my_file'); to load it.
If you need the JS outside of the CP as well, you need to put it in the /themes/third_party/your_addon_package/ folder and add a <script> tag to the header, if you want to use it in the CP.
If you want to output the JS file URL in your templates, create a method in your mod file that outputs URL_THIRD_THEMES.'your_addon/js/file.js' or something like that. Then use {exp:your_addon:your_method} to output the URL in the template.
themes folder. How do I then get the path to it for the <script> tag, without hard-coding the site URL?
URL_THIRD_THEMES constant (docs) (assuming you will be distributing your JS in the themes/third_party folder).
EE->cp->add_to_head() cannot be used in the front end, as the CP class is unavailable.
themes folder, but want to add it to the CP's head. If you want to generate the URL for templates, create a method in your mod file that outputs URL_THIRD_THEMES.'your_addon/js/file.js' or something like that. Then use {exp:your_addon:your_method} to output the URL in the template.
{exp:my_module}tags are used) or back-end (in you module's control panel)?