A Note on Javascript
In the course of web design, it has become popular to include various javascript code snippets to perform various functions within a site; often they can be used for browser-compatibility checks, basic dynamic content, and to provide the most accurate and accessible webpage to a viewer based on pertinent data provided to the server. These scripts are often called inline from the HTML within a site; in the interest of bandwidth, it is a good idea to avoid this whenever possible.
Taking a javascript program and putting it into an external file, then calling this script in a webpage header instead of writing out the entire script inline, serves to cache the script instead of forcing the browser to reload it every time a page is reloaded, especially if every page on a site calls the same set of scripts.
If embedding is required, be very careful to properly bracket the script.
is the correct method of declaring an inline javascript snippet. Often, WYSIWYG code editors may mangle this declaration, often omitting type="text/javascript" entirely. This informal style is one of the most significant causes of erratic javascripts, and should be strictly avoided.
Taking a javascript program and putting it into an external file, then calling this script in a webpage header instead of writing out the entire script inline, serves to cache the script instead of forcing the browser to reload it every time a page is reloaded, especially if every page on a site calls the same set of scripts.
If embedding is required, be very careful to properly bracket the script.
<script type="text/javascript" language="JavaScript">
</script>is the correct method of declaring an inline javascript snippet. Often, WYSIWYG code editors may mangle this declaration, often omitting type="text/javascript" entirely. This informal style is one of the most significant causes of erratic javascripts, and should be strictly avoided.


<< Home