Answer & Solution
<container>
<script src='app.js'>
</container>
.
<container>
<script src='app.js'>
</container>
.
What is the purpose of using external JavaScript files?
A). To keep HTML and JavaScript code separate
B). To reuse the JavaScript code on multiple pages
C). To improve the maintainability of the code
D). All of the above
How can you include multiple external JavaScript files in a web page?
A). Use multiple <container>
<script>
</container>
tags
B). Separate file names with commas
C). Separate file names with semicolons
D). Use a single <container>
<script>
</container>
tag with multiple src attributes
Can an external JavaScript file contain HTML?
A). Yes
B). No
C). Only if it is within a <container>
<script>
</container>
tag
D). Only if it is within a <container>
<body>
</container>
tag
How can you prevent an external JavaScript file from being cached by the browser?
A). Add a query string to the src attribute
B). Use the async attribute
C). Use the defer attribute
D). It is not possible to prevent caching
Where should the <container>
<script>
</container>
tag be placed in HTML?
A). In the <container>
<head>
</container>
section
B). In the <container>
<body>
</container>
section
C). At the end of the <container>
<body>
</container>
section
D). All of the above
What happens if the external JavaScript file is not found?
A). The browser will ignore the script
B). The browser will show a 404 error
C). The script will not run
D). All of the above
What is the difference between the defer and async attributes in the <container>
<script>
</container>
tag?
A). defer delays execution until after the HTML document is fully parsed, while async executes as soon as it is downloaded
B). defer executes the script immediately, while async delays execution until after HTML parsing is complete
C). defer and async both delay script execution until after HTML parsing is complete
D). There is no difference between defer and async attributes
How do you include an external JavaScript file in an HTML file?
A). <container>
<script src='filename.js'>
</container>
B). <container>
<script href='filename.js'>
</container>
C). <container>
<script link='filename.js'>
</container>
D). <container>
<script file='filename.js'>
</container>
What attribute is used to specify the path of an external JavaScript file?
A). href
B). src
C). path
D). file
Can an external JavaScript file be cached by the browser?
A). Yes
B). No
C). Only if specified in the HTML
D). Only if it is under a certain size