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. 

  • 相关阅读:
    haar特征(转)
    《统计学习那些事》转
    假设空间与概念空间(版本空间)
    opencv入门指南(转载)
    C++ 中的指针、引用以及函数调用中的问题
    关于python中的module
    Bugzilla 使用指南
    创新方法培训 学习总结
    集成产品开发-IPD简介
    SVN之文件同步更新
  • 原文地址:https://www.cnblogs.com/tekkaman/p/2869573.html
Copyright © 2011-2022 走看看