• used to include CSS
  • Placements:

  • HTML parsing is blocked, the script is fetched and executed immediately
  • HTML parsing resumes after the script is executed
  • Placement:
    • Place library scripts or event scripts in the head section.
    • Place normal scripts that do not write anything on the page, in the head section until there is any performance issue.
    • Place scripts that render something on the web page at the bottom of the body section.

  • The script will be fetched in parallel to HTML parsing and executed as soon as it is available
  • Use async when the script is independent of any other scripts on the page, for example, analytics

  • The script will be fetched in parallel to HTML parsing and executed when the page has finished parsing
  • If there are multiple of them, each deferred script is executed in the order they were encountered in the document
  • If a script relies on a fully-parsed DOM, the defer attribute will be useful in ensuring that the HTML is fully parsed before executing
  • A deferred script must not contain document.write