web Technology

Practical Tips for Writing Scripts

Reusable Functions

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:

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.