What is the primary purpose of the ‘defer’ attribute when loading an external JavaScript file?

Web Development Medium

Web Development — Medium

What is the primary purpose of the ‘defer’ attribute when loading an external JavaScript file?

Key points

  • Defer preserves script execution order
  • Defer waits for DOMContentLoaded
  • Async executes as soon as the script downloads

Ready to go further?

Related questions