Changes

Jump to: navigation, search

Embedding JavaScript into Web pages

4 bytes removed, 17:29, 11 April 2007
Whether to use inline or external JavaScript
The above example instructs the browser to load the JavaScript from the ''myjscript.js'' file located on the /j-scripts sub-directory of the local web server. It is possible to specify any valid URL here so this could be a file located on any accessible web server if required. Note that the script contained in the external ''.js'' file does not require the ''<script>'' and </script> elements.
== Whether Where to use inline or external place JavaScript in a Web Page ==
In the this section we have looked and both inline and external JavaScript (using the ''src'' argument of the ''<script>'' element). The question now arises as to which is the best approach. The general recommendation is that JavaScript functions should be placed in external ''src'' files wherever possible. The reasoning behind this is that if you have JavaScript code that is used on multiple plages you can modify this code in one place (the external JavaScript file) without having to edit every page that contains the code.

Navigation menu