HTML
href
href中的非URL字符会被转译,所以href跳转后的地址异常,肯定是多了额外的无用内容。
script
async:文件下载完后执行,并阻塞DOM解析(表现为DOM不再生成)
deffer:DOM解析完毕后,才会执行,所以不会阻塞DOM解析。
We also have a magical defer
attribute for the script
element which works similar to the async
attribute but unlike the async
attribute, the script doesn’t execute even when the file is fully downloaded. All defer
scripts are executed once the parser has parsed all HTML which means the DOM tree is fully constructed. Unlike async
scripts, all defer
scripts are executed in the order they appear in the HTML document (or DOM tree).
All normal scripts (embedded or external) are parser-blocking as they halt the construction of DOM. All async
scripts (AKA asynchronous scripts) do not block parser until they are downloaded. As soon as an async
script is downloaded, it becomes parser-blocking. However, all defer
scripts (AKA deferred scripts) are non-parser-blocking script as they do not block the parser and execute after the DOM tree is fully constructed.