User Interface - The browser interface, which includes the address bar, the back and forward buttons, bookmarks menu, etc. Includes everything except the requested page content
Browser Engine - Manages the interaction between the UI and the rendering engine
Rendering Engine - Displays, or renders, the requested page content. If the requested content is HTML, it will parse HTML and CSS and render the parsed content.
Networking - Handles network calls, such as HTTP requests
JS Interpreter - Parses and executes JavaScript code
UI Backend - Used for drawing basic widgets like combo boxes and windows; uses operating system user interface methods
Data Storage - The persistence of data stored in the browser, such as cookies
request
Network
tab of your browser’s Developer Tools to view these requests and responses.window
Object<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="entry.js"></script>
</head>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<body>
</body>
</html>
async
keyword in a script will fetch the script asynchronously and order of scripts run may be different than specified (whatever script gets loaded first)defer
keyword in a script will make it so the script executes only after page has been loadedwindow.onload
window.onload
will be called when the HTML, CSS, images and everything is loadedwindow.onload = () => {
console.log('this is printed only after all the HTML elements are displayed');
};
DOMContentLoaded
event listenereventListener
on DOMContentLoaded
or when all the HTML elements, or the document has been loaded (doesn’t wait for CSS or images)window.addEventListener('DOMContentLoaded', () => {
console.log('this is printed only after all the HTML elements are displayed');
});
body
of a page<!DOCTYPE html>
<html lang="en">
<head>
</head>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<body>
</body>
<script async>
console.log('this is printed only after all the HTML elements are displayed');
</script>
</html>
defer
keyword in a script
tag<!DOCTYPE html>
<html lang="en">
<head>
<script defer type="text/javascript" src="entry.js"></script>
</head>
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<!--------------------------------------------------------------------------------------------------->
<body>
</body>
</html>
Application
tab in your Chrome Dev Tools
Application
tab and refresh to see changes when those cookies are deleted