Overview: The composition of JavaScript, the role of each component,
One, the composition of JavaScript
Javascript
ECMAScript (CORE) DOM (Document Object model) BOM (Browser object model)
1.1ECMAScript
ECMAScript is a ECMA-262 standardized scripting language that ECMA-262 language: syntax, type, statement, keyword, reserved word, operator, object
1.2 DOM
The DOM maps the entire page to a multi-tiered node structure, and each component of the page, HTML or XML, is a type of node that contains different types of data.
1.3 BOM
Control the part of the page that the browser displays
Second, <script> elements
2.1 Use Mode
External referencing JavaScript file:
Copy Code code as follows:
<script type= "Text/javascript" src= ". /.. /xx.js "></script>
Page embedding JavaScript code
Copy Code code as follows:
<script type= "Text/javascript" >
var first= "First variable";
alert (a);
</script>
Properties of 2.2 <script> elements
Defer delay script: The script will be delayed until the entire page is resolved to execute, although it is deferred execution, but the browser has downloaded the JS file.
Copy Code code as follows:
<! DOCTYPE html>
<script type= "Text/javascript" defer= "defer" src= "Demo.js" ></script>
In the example above, although the <script> tag is in the
Defer only applies to externally introduced script files
Async Asynchronous Script: Do not have to let the page wait for the script to download and execute, thus asynchronously load the other content of the page. Therefore, the asynchronous load script does not modify the DOM during load.
Copy Code code as follows:
<! DOCTYPE html>
<script type= "Text/javascript" defer= "defer" src= "demo1.js" >
<script type= "Text/javascript" defer= "defer" src= "Demo2.js" ></script>
Are some of the basics of JavaScript, I hope we do not read to sleep, only to lay a good foundation for the possibility of qualitative change oh.