AiTechWorlds
AiTechWorlds
Before writing a single line of code, every web developer should understand what happens behind the scenes when a user visits a website. This foundation shapes every decision you make as a developer.
Type https://example.com into your browser and press Enter. Here is the chain of events:
Your browser doesn't know what example.com means as a network address. It asks a DNS (Domain Name System) server to translate the domain into an IP address, like 93.184.216.34.
Think of DNS as the internet's phone book it maps human readable names to machine readable addresses.
Your browser opens a TCP connection to the server at that IP address, usually on port 80 (HTTP) or port 443 (HTTPS). For HTTPS, a TLS handshake also happens here to establish encryption.
The browser sends an HTTP request to the server:
GET / HTTP/1.1
Host: example.com
Accept: text/html
User-Agent: Mozilla/5.0 ...The server responds with an HTTP response:
HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html>
<head><title>Example</title></head>
<body><h1>Hello World</h1></body>
</html>The browser receives the HTML and begins rendering the page more on this below.
Every webpage is built from three technologies, each with a distinct job:
| Technology | Role | Analogy |
|---|---|---|
| HTML | Structure and content | The skeleton |
| CSS | Visual presentation | The skin and clothes |
| JavaScript | Behavior and interactivity | The muscles |
<!-- HTML defines what exists -->
<button class="btn" id="subscribe">Subscribe</button>/* CSS defines how it looks */
.btn {
background: #0070f3;
color: white;
padding: 10px 20px;
border-radius: 6px;
border: none;
cursor: pointer;
}// JavaScript defines what it does
document.getElementById('subscribe').addEventListener('click', () => {
alert('Thanks for subscribing!');
});A web server (like Nginx or Apache) serves static files. An application server (like a Node.js or Python app) runs code to build responses dynamically querying a database, authenticating users, processing forms.
HTTP defines methods (also called verbs) that describe the intent of a request:
| Method | Use |
|---|---|
GET | Retrieve data (loading a page, fetching an API result) |
POST | Submit data to create a resource (sign up form, new post) |
PUT | Replace an existing resource entirely |
PATCH | Partially update a resource |
DELETE | Remove a resource |
// GET — fetch a list of posts
fetch('/api/posts')
// POST — create a new post
fetch('/api/posts', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: 'Hello World', content: '...' })
})
// DELETE — remove post with id 42
fetch('/api/posts/42', { method: 'DELETE' })Every HTTP response includes a status code that tells the client what happened:
| Code | Meaning |
|---|---|
200 OK | Request succeeded |
201 Created | Resource was successfully created |
301 Moved Permanently | URL has permanently moved (redirect) |
400 Bad Request | The client sent malformed data |
401 Unauthorized | Authentication required |
403 Forbidden | Authenticated but not allowed |
404 Not Found | Resource does not exist |
500 Internal Server Error | Something broke on the server |
In your code, always check status codes before using response data:
const res = await fetch('/api/user/profile');
if (res.status === 401) {
redirectToLogin();
} else if (res.ok) { // ok is true for 200-299
const data = await res.json();
renderProfile(data);
} else {
showError('Something went wrong.');
}A REST API (Representational State Transfer) is a convention for structuring HTTP based communication between a client and a server. REST APIs use URLs to represent resources and HTTP methods to define actions:
GET /api/articles → list all articles
GET /api/articles/7 → get article with id 7
POST /api/articles → create a new article
PUT /api/articles/7 → update article 7
DELETE /api/articles/7 → delete article 7Data is typically exchanged in JSON format. REST APIs power most of the web you interact with daily.
Once the browser receives an HTML document, it follows a precise sequence to paint pixels on screen:
This is why loading a large CSS file blocks rendering the browser needs the complete CSSOM before it can build the render tree. Always load critical CSS in the <head> and defer non critical JavaScript.
Every browser ships with DevTools (open with F12 or Ctrl+Shift+I). Key panels you will use constantly:
Open the Network tab, reload any webpage, and click a request. You will see the exact HTTP headers, status code, and response body everything covered in this lesson, in action.
Understanding this pipeline makes you a better debugger, a faster developer, and a more confident architect of web applications.
Get this course's notes on Telegram!
Free cheat sheets, summaries & practice exercises