Js is single-threaded, browsers are multi-process, so js execution and DOM rendering order:

Figure 2: Async page rendering, script tag encountered, page rendering, javascript download, JS execution, the end of execution, the page continues rendering figure 2: Async page rendering, script tag encountered, page rendering, js download parsing, after parsing, JS execution, page rendering stopped, after execution, the page rendering

Figure 3: defer page rendering, encounter script, page rendering, download JS and parse, page rendering, JS execution begins

Similarities and differences: Both Async and defer are asynchronous in terms of network download. Compared with HTML parsing, async is executed immediately after downloading. Each asynchronous script does not need to care about whether other scripts have finished executing. And network request and download file size about the defer after finish all HTML parsing, executed, and execute sequentially