Consider this scenario: You are loading a script (script 1) on your page which two other scripts rely on to function (scripts 2 and 3). All of these scripts can be safely executed after construction of the DOM. Which of the following approaches would work when loading these scripts? Select all that apply.
Choose an answer
Tap an option to check your answer.
Correct answer: Load script 1 normally (without an async or defer) attribute and load scripts 2 and 3 with the defer attribute., Load all 3 scripts with the defer attribute, making sure to include script 1 first in the HTML..
Why this is the answer
This works only when script execution preserves the dependency order after the DOM is built. One valid pattern is to let the dependency load as a normal blocking script and place the two dependent files behind it with defer , because deferred scripts wait until parsing finishes. Another valid pattern is to use defer on all three files, because deferred scripts execute in document order, so the dependency still runs first. Using async for all three would break that guarantee, since asynchronous scripts can execute as soon as they finish downloading rather than in HTML order. HubSpot Developers+1
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed