The code sample below shows how to append a single file to the head of the page, but using an array or something similar this would be very easy to incorporate multiple files.
Other advantages this approach gives you are
- Modular files - Using this approach you can modularise your code, meaning that all code that implements a specific feature can be contained within a single code file.
- Developer separation - If all your developers have their own source files then this mitigates the risk of one developer overwriting some changes another developer has made
- Source control - Since the files are hosted as physical files in another website, rather than saved to the interact file system, you can easily include this code in your source control system
- Deploying between environments - The standard approach to copying code changes between environments such as sandbox and live is to copy and paste between them. Copy and paste is prone to human error, but using this approach means you simply load the file in the second environment for instant deployment
Updated over 6 years ago