zoukankan      html  css  js  c++  java
  • js之defer&async

    js之defer&async

      This synchronous or blocking script execution is the default only. The <script> tag can have defer and async attributes, which (in browsers that support them) cause scripts to be executed differently. These are boolean attributes—they don’t have a value; they just need to be present on the <script> tag. HTML5 says that these attributes are only meaningful when used in conjunction with the src attribute, but some browsers may support deferred inline scripts as well:

    <script defer src="deferred.js"></script> <script async src="async.js"></script>

    Both the defer and async attributes are ways of telling the browser that the linked script does not use document.write() and won’t be generating document content, and that therefore the browser can continue to parse and render the document while down- loading the script. The defer attribute causes the browser to defer execution of the script until after the document has been loaded and parsed and is ready to be manip- ulated. The async attribute causes the browser to run the script as soon as possible but not to block document parsing while the script is being downloaded. If a <script> tag has both attributes, a browser that supports both will honor the async attribute and ignore the defer attribute. 

        Note that deferred scripts run in the order in which they appear in the document. Async scripts run as they load, which means that they may execute out of order. 

  • 相关阅读:
    Django 标签过滤器
    Python短路原则
    python学习之路 八 :面向对象编程基础
    python学习之路 七 :生成器、迭代器
    python学习之路 六 :装饰器
    python学习之路 五:函数式编程
    python学习之路 四 :文件处理
    python学习之路 三:字符编码
    机器学习流程管理
    pyspark 自定义聚合函数 UDAF
  • 原文地址:https://www.cnblogs.com/tekkaman/p/2869573.html
Copyright © 2011-2022 走看看