Answer & Solution
<body> section have a local scope by default, meaning they are only accessible within the script block or function where they are defined and cannot be accessed from outside that scope.
<body> section of an HTML document have what scope by default?
<body> section have a local scope by default, meaning they are only accessible within the script block or function where they are defined and cannot be accessed from outside that scope.
Using the defer attribute with an external script in the <head> section means that the script:
A). Loads and executes after HTML parsing.
B). Loads synchronously with HTML parsing.
C). Loads and executes before HTML parsing.
D). Loads but doesn't execute.
Which attribute can be used to make external JavaScript files load asynchronously in the <head> or <body> sections?
A). async
B). defer
C). sync
D). load
Placing JavaScript at the end of the <body> section is beneficial for:
A). Improving page load speed.
B). Blocking page rendering.
C). Increasing script complexity.
D). Hiding script functionalities.
Which of the following is a recommended practice for optimizing JavaScript performance?
A). Minify and concatenate scripts.
B). Include all scripts in the <head>.
C). Use synchronous loading for all scripts.
D). Load scripts without optimization.
Which attribute is used to make an external JavaScript file load and execute after HTML parsing but before the DOMContentLoaded event in the <head> section?
A). async
B). defer
C). sync
D). load
When JavaScript is placed in the <head> section of an HTML document, it can:
A). Execute before page rendering.
B). Execute after page rendering.
C). Block rendering until execution.
D). None of the above.
Using the defer attribute with an external JavaScript file in the <body> section means that the script:
A). Loads and executes after HTML parsing.
B). Loads synchronously with HTML parsing.
C). Loads and executes before HTML parsing.
D). Loads but doesn't execute.
When using an external JavaScript file in the <head> section with the defer attribute, when does it get executed?
A). After the HTML content is fully parsed.
B). Before the HTML content is parsed.
C). As soon as it starts loading.
D). After all other scripts in the <head>.
Variables declared in the <head> section of an HTML document are accessible:
A). Globally throughout the document.
B). Only within the <head> section.
C). Only after the page has fully loaded.
D). Nowhere in the document.
How can JavaScript be loaded asynchronously in the <body> section without blocking page rendering?
A). Using the defer attribute.
B). Using the async attribute.
C). Including scripts in the <head>.
D). Not possible in the <body>.