We can’t do this without you! Help us stay online and support free content.  Click to Donate

Fill in the blank: Add the ________ attribute to your script

Fill in the blank: Add the ________ attribute to your script to tell the browser to execute it after construction of the DOM.

Question: Fill in the blank: Add the ________ attribute to your script to tell the browser to execute it after construction of the DOM.

  • defer
  • preload
  • async
  • integrity

Explanation

The correct attribute is defer because it tells the browser to download the script without blocking HTML parsing and execute it after the DOM has been constructed. HubSpot’s performance guidance specifically recommends async or defer for script loading, and defer is the option used when execution should wait until parsing is complete. This preserves document order for deferred scripts, which also makes it suitable for dependent scripts that must run after the page structure is available. The other listed attributes serve different purposes and do not provide this execution timing behavior. HubSpot Developers

Why the other options are incorrect

preload is a resource hint for fetching assets earlier, not a script execution control that waits until after DOM construction.

async allows a script to execute as soon as it finishes downloading, so it does not guarantee execution after parsing completes or preserve script order. HubSpot Developers

integrity is used for Subresource Integrity verification, not for controlling when a script executes.

Source for verification

https://developers.hubspot.com/docs/cms/best-practices/testing-staging-performance/speed

The answer(s) to the question is highlighted in the BOLD text above. You can also find more questions and answers related to the exams on the "HubSpot CMS for Developers II" page.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top