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. 

  • 相关阅读:
    React Native ActivityIndicator(菊花组件)
    React Native 自定义ListView 分区表
    React Native 自定义ListView
    React Native ListView数据展示
    React Native ScrollView 添加图片数组
    模仿UC新闻标签编辑功能
    React Native ScrollView缩放
    React Native 之 TextInput(多个语法知识)
    React Native 之 Flexbox(弹性盒子布局)
    React Native 之 Flex
  • 原文地址:https://www.cnblogs.com/tekkaman/p/2869573.html
Copyright © 2011-2022 走看看