devxlogo

Reference an External JavaScript File

Reference an External JavaScript File

Question:

How do you reference an external JavaScript file from an HTML page?

Answer:

You can reference an external JavaScript file from your HTML page similar to the way you’d reference an image. The syntax is:

This will make your browser download the mycode.js file and interpret the JavaScript code within it?just as if it were included in your page. As with an image, you can use any URL that points to a JavaScript file, including ones on servers other than your own. Note: It is very important that you include a closing tag within your HTML file. The external reference will not work without it.

devx-admin

Share the Post: