B

Babita • 7.70K Points
Tutor III

Q. Which attribute is used to specify that the script is executed when the page has finished parsing ( only for external scripts )

  • (A) parse
  • (B) a sync
  • (C) defer
  • (D) type

Explanation by: Official MCQ Buddy

The defer attribute ensures that an external script is executed only after the HTML document has been fully parsed. This prevents blocking the rendering process, improving page load performance.

Key Differences Between defer and async:

  • defer → Scripts execute in order, after the HTML is fully parsed.
  • async → Scripts execute as soon as they are downloaded, potentially before the HTML is fully parsed.

Why the other options are incorrect:

  • (A) parse → No such attribute exists in HTML.
  • (B) async → Executes the script as soon as it is downloaded, not after parsing is complete.
  • (D) type → Defines the type of script (e.g., "text/javascript"), but doesn’t control execution timing.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.