Browsers are complex applications that do much more than just displaying HTML pages. They are essentially a full-fledged operating system with many components working together to load and render web pages.
When you load a web page in your browser, several things happen behind the scenes:
- The browser loads the HTML file. It converts the raw bytes into characters using the specified encoding, usually UTF-8. It then tokenizes the HTML into elements like <h1>, <p>, etc. It creates DOM objects and establishes relationships between them. This results in the DOM tree.
- The browser also loads any CSS files referenced in the HTML. It follows a similar process of converting bytes to characters, tokenizing into selectors, creating style objects and building the CSSOM (CSS Object Model).
- The browser's rendering engine combines the DOM and CSSOM to build the render tree. This involves applying styles, calculating layout and positioning of elements.
- As the browser encounters <script> tags, it will pause the rendering process, load and execute the JavaScript. The JavaScript can then modify the DOM.
- The browser then starts painting the render tree to the screen, displaying the finished webpage.
- The browser also handles user interactions, network requests, and JavaScript execution to provide an interactive experience.
The rendering engine, written in C++, is responsible for taking the HTML, CSS and JavaScript and converting it into low-level commands for displaying and interacting with the webpage. The rendering process is complex but ultimately results in the webpage we see.
Hope this overview helps explain at a high level how browsers work! Let me know if you have any other questions. Thanks
Hitesh Choudhary
for bringing these inner engineering ,curiosity igniting content.
useAbout((skills) => skills?.javascript?.reactjs?.nextjs);
1 年hashnode link - https://gyandeeparyan.hashnode.dev/inner-engineering-of-browsers related Video - https://www.youtube.com/watch?v=5rLFYtXHo9s&t=2s