fullstack_webdev

Code and notes from Full stack web developer path, LinkedIn Learning.

View on GitHub

02. Up and Running with JS

02.01 JavaScript in HTML Document


02.02 Writing JavaScript in an external file


02.03 Modern Javascript Loading: Async and Defer


02.04 JavaScript Modules

-

Wrap up:

  1. When does the browser execute JavaScript?

    By default: When the script is encountered. If the script is set to “async”, when the script is fully loaded. If the script is set to “defer”, when the entire HTML page is rendered.

  2. What is the correct markup for adding an external JavaScript file to an HTML document?

    <script src="javascript.js" async></script> While <script src="javascript.js"></script> is technically correct, it is recommended to always async or defer your script unless you have a specific reason for the script to cause render blocking.

  3. What happens when you defer JavaScript?

    The browser loads the JavaScript asynchronously when it is encountered, then waits until all HTML is rendered before executing the script.

  4. JavaScript modules are heavily used in frameworks like React and Vue. What is the advantage of using modules?

    Modules enable modularization of code where individual functions, components, data objects, and other parts can be separated into individual files.