When you type a URL (like priorcoder.com) into your browser’s address bar and press enter, a fascinating series of events begins. These steps are intricate and involve various layers of hardware and software working together to fetch and display the webpage you requested. Let’s break down the process into simple steps and explain each one in detail.
When you press a key on your keyboard, several things happen at the hardware level before your computer even knows what key you’ve pressed.
Once you’ve finished typing the URL and pressed “Enter,” the browser needs to figure out what you’ve typed. Is it a valid URL, or is it a search query?
If the URL contains special characters (like ñ or é), the browser converts them into a format that the web can understand, called Punycode. This ensures that the URL can be properly processed by web servers.
The browser checks a preloaded list of websites that require secure connections (HTTPS). If the website is on this list, the browser will automatically use HTTPS, ensuring your connection is secure from the start.
The browser needs to find the IP address of the server that hosts the website. This process is called a DNS (Domain Name System) lookup.
Before sending data to the DNS server or the website, your computer needs to know where to send it. The ARP (Address Resolution Protocol) process helps map the IP address of the target server to a physical MAC address on the network.
Now that your computer knows where to send the request, it opens a TCP (Transmission Control Protocol) socket to communicate with the server.
If you’re using HTTPS, a TLS (Transport Layer Security) handshake occurs next. This ensures that the data sent between your browser and the server is encrypted and secure.
With the connection established and secured, your browser sends an HTTP request to the server asking for the webpage. This request might look something like this:
The server receives your request, processes it, and sends back the webpage’s HTML, along with other resources like CSS files, JavaScript, and images.
The browser starts parsing the HTML it received from the server. This is the beginning of turning code into the visual webpage you see.
Next, the browser processes any CSS it received, which controls the visual style of the page, including colors, fonts, and layouts.
If the page includes JavaScript, the browser’s JavaScript engine executes the code, adding interactivity to the page. This could include things like animations, form validation, or fetching additional data.
With the DOM, CSS, and JavaScript processed, the browser can now render the page.
As the browser renders the page, it might encounter additional resources (like images or scripts) that need to be loaded. The browser repeats the process of sending HTTP requests and receiving responses for these resources.
Once all resources are loaded and rendered, the browser considers the page fully loaded. At this point, any JavaScript that was deferred until the end of the loading process is executed.
Even after the page is fully loaded, the browser continues to handle user interactions (like clicks, typing, or scrolling) and server communication. JavaScript can modify the page dynamically, and the browser will re-render the affected parts.