What exactly is the benefit of the HTML5 async attribute on script elements?

前端 未结 6 1982
伪装坚强ぢ
伪装坚强ぢ 2021-02-07 00:33

I have some confusion around the new async attribute to the script element in HTML5 that I hope someone can give a clear answer to.

Browsers are capable of Parallel Conn

6条回答
  •  一向
    一向 (楼主)
    2021-02-07 01:35

    The async attribute is just a clearer (no ambiguity very straightforward) and cleaner (it will, or is already, part of the respected HTML5 specification) approach to solve the problem. If your site serves scripts from another domain (or CDN) then the async attribute gives you a little reliability (allow the user to at least read the static content) in that the page won't block while a script from a slow (possibly down) remote host is trying to load.

提交回复
热议问题