- Advertisement -

How to Add JavaScript in HTML Document? – GeeksforGeeks

0

Last Updated :
15 Nov, 2024

To add JavaScript in HTML document, several method can be used. These methods include embedding JavaScript directly within the HTML file or linking an external JavaScript file.
Table of Content
Inline JavaScript Internal JavaScript (Within 2. defer Attribute The defer attribute delays the execution of the script until the entire HTML document has been parsed. This is particularly useful for scripts that manipulate the DOM.
How to Reference External JavaScript Files? We can reference an external script in three ways in javascript:
By using a full URL: src = “https://www.geeksforgeek.org/js/https://www.geeksforgeeks.org/where-to-put-javascript-in-an-html-document/script.js” By using a file path: src = “/js/https://www.geeksforgeeks.org/where-to-put-javascript-in-an-html-document/script.js” Without using any path: src = “https://www.geeksforgeeks.org/where-to-put-javascript-in-an-html-document/script.js”

Leave A Reply

Your email address will not be published.