How to define the URL of an external script file in HTML5 ? Last Updated : 24 Mar, 2021 Comments Improve Suggest changes Like Article Like Report In this article, we will learn how to define the URL of an external script file inside HTML. This may be needed when a large script code is needed to be included, and it may create confusion if all the code is written in a single file. Also, there may be a requirement for the same script to execute on different web pages, and rewriting the same code can lead to redundancy. The code can be refactored by simply writing the script code in a separate file and defining it in the HTML file. Approach: The script tag has an attribute src which is used to specify the path of an external script file. Syntax: <script src="examplescript.js"></script> Example: In this example, the examplescript.js external script to be included in the HTML file. examplescript.js alert("The script file URL is successfully defined"); index.html <html> <body> <h1 style="color: green"> GeeksforGeeks </h1> <!-- Including an external script --> <script src="examplescript.js"> </script> </body> </html> Output: On loading the page in our browser, we will get a pop-up with the defined message which confirms that the external script has properly loaded. Comment More infoAdvertise with us Next Article How to define the URL of an external script file in HTML5 ? G greenblade29 Follow Improve Article Tags : Web Technologies HTML HTML5 HTML-Tags HTML-Questions +1 More Similar Reads How to define the URL of the video file in HTML5? In this article, we will learn how to define the URL of a video in HTML. The <video> tag is used to embed video files on a web page. This displays a video player along with the player controls depending on the browser. The source of the video can either be a singular one or it can be made to s 3 min read How to specify the URL of the media file in HTML5 ? Here we will see how to set the URL of a media file using HTML. To set the URL of media file we use <source> tag. This tag is used to attach multimedia files like audio, video and pictures. The <audio>, <video> and <picture> elements contain the <source> element. Syntax 1 min read How to define a client-side script in HTML5 ? To define a client-side script in HTML5, we can do <script> tag or adding external script file by src attribute to the HTML file. <script> tag contains the JavaScript to be added for the client-side scripting. Syntax: <script> // JavaScript goes here console.log('GeeksforGeeks'); 1 min read How to define an embedded object in HTML5 ? In this article, you will learn how to define an embedded object by using the <object> element in the document. It is used to display multimedia objects like audios, videos, images, PDFs, and Flash in web pages. The element is also used for displaying any other webpage on an HTML page. This ta 1 min read How to Link JavaScript File to a Separate HTML File? Linking a JavaScript file to an HTML document creates a connection that enables the execution of JavaScript code within the webpage. This is commonly achieved using the <script> tag in the HTML file, where the src attribute specifies the path to the external JavaScript file. Approximately 90% 2 min read Like