To start, lets walk through a very basic "Hello World" web page. Assume that the server at helloworld.com has this HTML file:
What happens immediately after a user enters the URL for helloworld.com and presses
First, the browser creates a HTTP request for index.html. The server returns the HTML as part of the HTTP response.
The browser feeds the HTML to it's DOM engine which begins processing the HTML and building a HTML document and its HTML elements. In this example, it creates a
DocumentElementwhen it sees the
htmltag, and a child
head elementwhen it sees the head tag.
ok. Once the user clicks
bodyelement and the
H1element, displaying the text "Hello Dom" to the user.
Now, if we change the script tag to
Our revised HTML:
<html> <head> </head> <body> <h1>Hello DOM</h1> <script src="js/helloworld.js"></script> </body> </html>
Code in languages like Java or C is compiled to byte or machine code. When your app runs, it reads instructions from code and operates on data.js
- functions don't belong to any object / class
- DOT operator
- NEW operator