Q
What is the purpose of using external JavaScript files instead of inline code?

Answer & Solution

Answer: Option A
Solution:
Using external JavaScript files instead of inline code reduces code redundancy and promotes code reusability, as the same script can be included and used across multiple HTML pages without duplicating the code.
Related Questions on Average

How can you include an external JavaScript file using the <script> tag?

A). <script src='script.js'></script>

B). <script>src='script.js'

C). <script type='text/javascript' src='script.js'></script>

D). <js src='script.js'></js>

Which attribute of the <script> tag is used to delay script execution until after the document is parsed?

A). type='defer'

B). async='false'

C). defer='true'

D). defer

Where is the recommended place to include external JavaScript files in an HTML document?

A). Inside the <head> section.

B). Before the closing tag.

C). After the opening tag.

D). Inside the <body> section, anywhere.

Which scenario is ideal for using the async attribute in the <script> tag?

A). When the script must be executed in a specific order.

B). When the script contains critical functionality that should not be delayed.

C). When the script can be executed independently and does not depend on other scripts or document elements.

D). When the script must be executed after the document is parsed.

What attribute of the <script> tag allows asynchronous loading of scripts?

A). type='async'

B). async='true'

C). defer='async'

D). async

Which of the following is true about inline JavaScript code execution?

A). It always executes before external JavaScript files.

B). It executes simultaneously with external JavaScript files.

C). It executes after external JavaScript files.

D). It depends on the order of inclusion in the HTML document.

What is the purpose of the <noscript> tag in HTML?

A). It specifies that JavaScript should not be executed on the page.

B). It provides fallback content for browsers that do not support JavaScript.

C). It includes external JavaScript files in the document.

D). It allows asynchronous loading of scripts.

When including multiple <script> tags in an HTML document, what determines the order of script execution?

A). The order in which the <script> tags appear in the HTML document.

B). The order specified by the async attribute in each <script> tag.

C). The alphabetical order of the script filenames.

D). The defer attribute in each <script> tag.

Which attribute is used to specify the location of an external JavaScript file in the <script> tag?

A). href

B). url

C). src

D). location

What is the correct way to include an inline JavaScript code block using the <script> tag?

A). <script type='text/javascript'>...</script>

B). <script inline>...</script>

C). <script>

D). <js>...</js>