External Js File Html Example
If you have more than one external javascript file then add it in the same web page to increase performance of the page.
External js file html example. It provides code re usability because single javascript file can be used in several html pages. Function display alert hello world. This extension as you probably have already guessed stands for. If you want to run the same javascript on several pages in a web site you should create an external javascript file instead of writing the same script over and over again.
So save the javascript code in a new file with the extension js. Html body form input type button value result onclick display form script src new js script body html. Now add the external javascript file to the html web page. In the external method the javascript code is contained in an entirely separate external document with a file extension of js.
An external javascript file must be saved by js extension. It is recommended to embed all javascript files into a single file. We can create external javascript file and embed it in many html page. Let s say the following new js is our external javascript file.