Summary: The composition of javascript, the role of each component,
1. The composition of javascript
javascript
ECMAScript (core) DOM (document object model) BOM (browser object model)
1.1ECMAScript
ECMAScript is a scripting language standardized through ECMA-262. ECMA-262 stipulates languages: syntax, type, statement, keyword, reserved word, operator, object
1.2 DOM
DOM maps the entire page into a multi-layer node structure. Each component in the HTML or XML page is a certain type of node, which contains different types of data.
1.3 BOM
Control the parts outside the page displayed by the browser
2. <script> elements
2.1 How to use
External reference to javascript files:
The code copy is as follows:
<script type="text/javascript" src="../../XX.js"></script>
Page embed javascript code
The code copy is as follows:
<script type="text/javascript">
var first="first variable";
alert (first);
</script>
2.2 Properties of <script> elements
defer delay script: The script will be delayed until the entire page has been parsed before it is executed. Although it is delayed, the browser has downloaded the js file.
The code copy is as follows:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" defer="defer" src="demo.js"></script>
</head>
</html>
In the above example, although the <script> tag is located in the <head> tag, demo.js will be delayed until the browser encounters</html>.
Defer is only applicable to externally imported script files
async asynchronous script: There is no need to let the page wait for the script to be downloaded and executed, so as to load other contents of the page asynchronously. Therefore, asynchronous loading scripts do not modify the dom during loading.
The code copy is as follows:
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" defer="defer" src="demo1.js">
<script type="text/javascript" defer="defer" src="demo2.js"></script>
</head>
</html>
All of them are basic javascript knowledge. I hope everyone will not be able to fall asleep when they read it. Only by laying a solid foundation can there be a possibility of qualitative change.