JavaScript series: JavaScript advanced Programming, Chapter2, using JavaScript in HTML

Source: Internet
Author: User

The 2.1.2 Delay script refers to the defer property and only applies to external scripts, that is, scripts that have defer properties.
Delaying scripts at the bottom of the page is still the best choice due to the lack of uniform support for deferred scripting by various delay browsers and the fact that the defer attribute is no longer supported after HTML5.

2.1.3 Asynchronous Script <script type= "text/javascript" async src= "Example1.js" ></script>
    <script type= "text/javascript" async src= "Example2.js" ></script>
The second script may be executed before the first script, so it is important to ensure that two scripts are not dependent on each other.
The purpose of specifying the async attribute is to not allow the page to wait for two scripts to be downloaded and executed to asynchronously load other content on the page. Therefore, it is recommended that asynchronous scripts do not modify the DOM during loading.
Asynchronous scripts must be executed before the Load event of the page, but may be executed before or after the domcontentloaded event is triggered.

2.1.4 usage in XHTML only such formats can be supported in a variety of browsers, although a bit hack flavor.
  
 
  1. <script type="text/javascript">
  2. <![CDATA[
  3. function compare(a, b){
  4. if(a<b)
  5. alert("A is less than B");
  6. else if(a>b)
  7. alert("A is greater than B");
  8. else
  9. alsert("A is equal B");
  10. }
  11. ]]>
  12. </script>

2.3 Document mode The calibration mode is very close to the standard mode, and their differences are negligible. So when someone proposes "standard mode", it is possible that either of the two patterns is in the same way.
2.4 <noscript> Elements
  
 
  1. <body>
  2. <noscript>
  3. <p> 页面需要浏览器支持</p>
  4. </noscript>
  5. </body>
This page displays a message to the user in case the script is invalid. In a script-enabled browser, the user will never see it.



    









From for notes (Wiz)

JavaScript series: JavaScript advanced Programming, Chapter2, using JavaScript in HTML

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.