Inline and External Javascript

Duration: 2 min

This video lesson is available to enrolled students.

Enroll to watch — NTA-UGC-NET Paper - 2

AI Summary

An AI-generated summary of this video lecture.

The video presents a lecture on integrating JavaScript into HTML documents, covering two primary methods. The first method, inline JavaScript, is demonstrated by showing the use of the <script> element within an HTML document, with a code snippet illustrating the basic syntax. The second method, external JavaScript, is introduced as a best practice for larger projects, where JavaScript code is saved in a separate file, such as script.js, and linked to the HTML document. The lecture also briefly touches on other HTML elements, including the <img> tag for images and the <a> tag for hyperlinks, providing their basic syntax and attributes.

Chapters

  1. 0:00 1:43 00:00-01:43

    The video begins with a discussion on including JavaScript in an HTML document using the <script> element. The instructor shows a code snippet for inline JavaScript, which is placed directly within the HTML file between <script> and </script> tags. The example includes a simple alert function. The instructor then transitions to the concept of external JavaScript, explaining that it is a good practice for larger projects. The text on the screen states, 'Separating JavaScript code into an external file is a good practice for larger projects. Save the JavaScript code in a separate file, for example, script.js.' The instructor also briefly mentions other HTML elements, such as the <img> tag for images and the <a> tag for hyperlinks, providing their basic syntax and attributes.

The lecture systematically introduces the two main ways to incorporate JavaScript into a web page: inline and external. It emphasizes that while inline JavaScript is suitable for small scripts, external JavaScript is a best practice for larger, more complex applications, promoting code organization and reusability. The lesson also provides a brief overview of other fundamental HTML elements, reinforcing the connection between HTML and JavaScript in web development.