Use Consistent Document Structure
Many times a script that applies to only a single page will be included with the HTML code instead of a separate file. By sticking to a consistent organizational structure within the code for the page as well, maintainability can be enhanced.
Group Embedded Script Code
Listing 1: Binding a Client-Side Script to an Event
Listing 2: Placing Code in the Event Attribute
While this is completely legal syntax, it is bad style. As much as possible, functional script code should be gathered together in one place for each of maintenance and reuse, not scattered throughout the document.
Position Within Head Tags Consistently
Script tags can appear anywhere in the HTML document, as long as they are defined (downloaded) before they are called. However, to simplify the task of finding and maintaining scripts in an HTML document, it's a good idea to group embedded scripts in the document head section either before or after style sheets and metatags. Use the same pattern in all source code files.