The Internet and the Browser

If you are taking this course, you should already have a solid foundation in programming with JavaScript. And you should know that JavaScript was developed as a 'glue' to HTML on websites, so that web designers could easily assemble components such as images and plugins back in 1995. Since then, JavaScript has been getting more and more powerful in the tasks it can perform on the browser. What exactly is a browser? And what can JavaScript do on it? Lets begin with a little history of the World Wide Web.

In 1991, Tim-Berners Lee invented the first website in the world. He did it because he wanted a convenient way for researchers at the CERN facility to share research materials with each other. The data of a researcher's materials were stored on his computer and when another researcher requests them, they will be sent to the requester's computer through CERN's internal network. The data were in the form of HTML files and made readable on a browser. Tim-Berners Lee wrote the first browser, and called it "WorldWideWeb".

Computers that store and distribute web content is called a web server. A web server would wait (listen) for another computer to make a request. If a request is valid, the web server will send the requested file to the requesting computer. The requesting computer, called the client, will then display the file in a human readable format on the browser.

The networking system for communication between computers was introduced to the general public as the Internet. There are many different ways computers can interact with each other. One of the earliest interaction was the sending and receiving of messages, called emails. The protocol that governs the sending and receiving of emails is called SMTP, short for Simple Mail Transfer Protocol. Other interactions on the Internet includes chat, file sharing, file streaming, remote access of distant computers and more. Each of those interactions would have a network protocol that governs how they work.

The base network protocol that all computers can perform is the Transmission Control Protocol (TCP). TCP provides reliable, ordered transmission of data from one computer to another. Many other network protocols rely on TCP, including emails, data streaming, remote access.

For sending and receiving website files, the protocol that provides the rules and mechanisms is called HTTP, short for Hypertext Transfer Protocol. HTTP is the foundation of the World Wide Web (WWW), which now means the information space where documents are shared through the Internet. Documents on the WWW are identified by their Uniform Resource Locators (URLs). Documents can be linked to each other using hypertext links, creating a web of documents, hence the name Web. A typical URL would look like this.

 http://www.altcademy.com/file.html
|      |                 |         |
protocol   server name      path

A URL consists of a protocol, a hostname (the name of the server hosting the files), and a file name. The file name will tell the server which particular file we are interested in. When we don't define a path, the server will just send us the data of the main page. The main page is usually the index.html file, since it serves the purpose of showing an index of the content stored on the server. The creator of a website can decide what the main page does. In the case of http://www.google.com, its purpose is to provide a search tool for the visitor to search for particular contents on the world wide web.

Server names such as www.google.com are easy for humans to remember, but computers don't identify each other in this format. Instead, all computers connected to the Internet get a unique IP address. It usually looks something like this '172.217.24.196'. This is an IP address of one of Google's servers. You can replace this with www.google.com and you will be able to connect to the server. The human readable name www.google.com is called a domain name. Once you have ownership to a domain name, you can register it to point to any IP address you like. In this case, www.google.com points to the server at '172.217.24.196'.

HTML is the file format for web page documents. Most of the file types that web servers host are HTML files. But a web server can host all kinds of file formats, such as videos, images, audio, text files and everything else. The earliest websites were simple HTML files for the purpose of providing research material. But as people starting discovering new uses for the Internet, engineers needed a way to add new functionalities to websites. A programming language called JavaScript was created to be executable on the browser (client-side). It allows engineers to add features like live chat, payment processing, animation and all kinds of interactivity to web pages.

The fundamental use case of JavaScript is its ability to manipulate content on a web page, such as:

  • JavaScript can add, change, and remove all of the HTML elements and attributes in the page.
  • JavaScript can change all of the CSS styles in the page.
  • JavaScript can react to all of the existing events in the page.
  • JavaScript can create new events within the page.
  • Animation of page elements, fading them in and out, resizing them, moving them, etc. WikiPedia

The other use case is JavaScript can utilize the networking protocols of a browser to communicate with other computers, clients and servers alike. This allows the user to post a new status update on a social network without leaving or refreshing a page. Because JavaScript is run on the browser, it makes the web browsing experience much faster and more responsive.

Enough about history, lets get to the code.

results matching ""

    No results matching ""