Learn JavaScript first from scratch (introduction)

Source: Internet
Author: User

Summary: The composition of JavaScript, the role of each component,

JavaScript is a scripting language designed to interact with Web pages, and its composition

Javascript
ECMAScript (CORE) DOM (Document Object model) BOM (Browser object model)


1.1ECMAScript

the Ecmascrip defined by ECMA-262 has no dependency on the Web browser, ECMA-262 defines only the basis of the language, providing core language functionality

ECMAScript is a standardized scripting language through ECMA-262, ECMA-262 language: syntax, type, statement, keyword, reserved word, operator, object

1.2 DOM (Document Object modle)

DOM is an application programming interface (Api,application programming Interface) for XML but extended for HTML, providing methods and interfaces for accessing and manipulating Web page content

The DOM maps the entire page to a multi-tiered node structure, and each component of the page, such as HTML or XML, is a node of a certain type, and these nodes contain different types of data.

1.3 BOM (Bower Object modle)

Controls the portion of the page that the browser displays, and the BOM only handles browser windows and frames, providing methods and interfaces for interacting with the browser

Second, <script> elements

2.1 referencing JavaScript files

    • Externally referencing JavaScript files:
<type= "Text/javascript"  src= ": /.. /xx.js "></script>
    • Page embedding JavaScript code
<type= "Text/javascript">//javascript code </ Script >

The JavaScript code contained within the <script> element will be interpreted from top to bottom

2.2 Properties of the <script> element

    • Defer delay script: tells the browser to download immediately, the script will be deferred until the entire page is parsed before execution, defer only applicable to externally introduced script files
<!DOCTYPE HTML><HTML>    <Head>         <Scripttype= "Text/javascript"defer= "Defer"src= "Example.js"></Script>    </Head></HTML>

Although the <script> tag is within the

    • Async Async Script: Must let the page wait for the script to download and execute, thus asynchronously loading the page other content

Same as defer only applies to externally introduced script files, Async tells the browser to download the file immediately, but unlike defer, it is not guaranteed that async scripts are executed in the order they are specified, and it is recommended that asynchronous scripts do not modify the DOM during loading

<!--Asynchronous Script -<Scripttype= "Text/javascript"Async= "Async"src= "Example1.js"></Script><Scripttype= "Text/javascript"Async= "Async"src= "Example2.js"></Script>

2.3 Properties of the <noscript> element

<!DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Test</title><!--Delay Script -<ScriptType= "Text/javascript"defer= "Defer"src= "Example.js"></Script><!--Guide Script -<Scripttype= "Text/javascript"Async= "Async"src= "Example1.js"></Script><Scripttype= "Text/javascript"Async= "Async"src= "Example2.js"></Script></Head><Body>   <NoScript>    <P>This page shows the need for browser support (enabled) Javascript</NoScript></Body></HTML>
    • Browser does not support scripting
    • The browser supports scripts, but the script is disabled and the browser displays the contents of <noscript>
    • This page displays a message to the user in case the script is invalid, and in a script-enabled browser, the user will never see it

Learn JavaScript first from scratch (introduction)

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.