Which of the following is a valid method to apply an external JavaScript file…

2025

Which of the following is a valid method to apply an external JavaScript file to an HTML document ?

  1. A.

    <script href="file.js">

  2. B.

    <script src="file.js">

  3. C.

    <javascript src="file.js">

  4. D.

    <script file="file.js">

Attempted by 62 students.

Show answer & explanation

Correct answer: B

The correct method to apply an external JavaScript file is using the src attribute within a script tag, as shown in option 2.

Explore the full course: Tpsc Assistant Technical Officer