Reputation: 87
I have a JavaScript file which has many functions that are used by various sections of my website, each of which is in its own sub-domain.
Will it be a good idea if I place the file in the root directory and have all the sub-domains link to that specific one or should I have a copy of the JavaScript file in each sub-domain and link to each one? The JavaScript file is updated with holiday dates, therefore it is updated regularly. It would mean updating them all if repeated...
Thanks in advance :)
Upvotes: 1
Views: 3911
Reputation: 7515
When I have multiple uses for a JavaScript or CSS file, but only want to update it once, I create a soft symbolic link
This is basically just an Operating System pointer that can point multiple "links" to a single file.
That way you update the single JavaScript file and it will seem like you have updated multiple JavaScript files across multiple sites.
For example
ln -s /path/to/your/actual/js/file/javascript.js /path/to/your/symlink/javascript.js
Here is a Wikipedia article explaining what Symlinks are.
Upvotes: 0
Reputation: 959
To save time (as well as space) and to make your project clean, it will be best to place the file in the main scripts
or js
folder.
So in other words, create a folder for all your scripts in the main project's root and place the file in it:
site
| - scripts
| - file.js
...
Once that is done, link all other sub-domains to that file.
Hope it helps :)
Upvotes: 2