Along with reusing other people's scripts and folders, you can also write code that you can reuse
yourself.Rather than writing a new script for each site, you can create a script that you can use on any contact form you write. So, you should aim to make your code as reusable as possible, rather than writing a script that will only
work with one page.
Using External JavaScript Files
Whenever you are going to use a script in more than one page it' s a good idea to place it in an external
JavaScript file. Rather than including this
script on every page, if the script lives in an external JavaScript file:
You do not have to copy and paste the same code into several files.
The file size of the pages is smaller because the JavaScript is in one file that is included on each
page rather than repeated in multiple pages.
If you need to change something about the script, you need to change only the one script, not
every page that uses it.
Place Scripts in a Scripts Folder
When you use external scripts you should create a special scripts folder — just as you would an
images folder. This helps improve the organization of your site and your directory structure. Whenever
you need to look at or change a script, you know exactly where it will be.
You should also use intuitive names for your script files so that you can find them quickly and easily.