<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Bishal kumar on Medium]]></title>
        <description><![CDATA[Stories by Bishal kumar on Medium]]></description>
        <link>https://medium.com/@kbishal922?source=rss-a7010c630858------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*vJV68AKRbCk0OTdM</url>
            <title>Stories by Bishal kumar on Medium</title>
            <link>https://medium.com/@kbishal922?source=rss-a7010c630858------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 24 May 2026 02:26:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kbishal922/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[Decoding HTML Script Placement: Async and Defer Explained]]></title>
            <link>https://medium.com/@kbishal922/decoding-html-script-placement-async-and-defer-explained-8a24d99c0453?source=rss-a7010c630858------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a24d99c0453</guid>
            <category><![CDATA[async]]></category>
            <category><![CDATA[html-parsing]]></category>
            <category><![CDATA[defer]]></category>
            <category><![CDATA[script]]></category>
            <category><![CDATA[async-vs-defer]]></category>
            <dc:creator><![CDATA[Bishal kumar]]></dc:creator>
            <pubDate>Fri, 26 Jan 2024 07:58:15 GMT</pubDate>
            <atom:updated>2024-01-27T16:35:23.135Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey, hope you like my first article on Medium and commented on your suggestions, if you haven’t view I request you to <a href="https://medium.com/@kbishal922/demystifying-browser-rendering-a-deep-dive-into-html-and-css-c944a4503c09">go</a> and read it because it’s very important to know about how the HTML &amp; CSS file is read by the browser and you will find it very interesting about it.</p><p>Ok, now it is time to know more about JS. Let’s go … 😎</p><h4><strong>1. &lt;script&gt; tag in header tag</strong></h4><ul><li>When the HTML parsing is in process and as soon as it encounters the <em>script</em> tag then the HTML parsing will stop and the downloading of the script file continues as soon as it is downloaded then it will start executing it.</li></ul><pre>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;title&gt;Hello, World!&lt;/title&gt;<br>    &lt;style&gt;<br>      .common {<br>        width: 200px;<br>        height: 60px;<br>        margin: 20px;<br>        background: rgba(0, 0, 255, 1);<br>        border-radius: 15px;<br>        font-size: large;<br>        color: white;<br>      }<br>    &lt;/style&gt;<br>    &lt;script&gt;<br>      const btn1 = document.getElementById(&#39;btn1&#39;);<br>      btn1.addEventListener(&#39;click&#39;, function (e) {<br>        alert(&#39;Btn1 is pressed&#39;);<br>      });<br>    &lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;button id=&quot;btn1&quot; class=&quot;common&quot;&gt;Button1&lt;/button&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><ul><li>The problem with this scenario is that in <strong>vanilla</strong> javascript, JS can manipulate the DOM by changing in appearance, hiding the element create an element. So, while executing the JS file it will through an error like the one below:-</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5bDuJcMPDK4Te6jxV_g28g.png" /></figure><h4>2. &lt;script&gt; tag with async attribute</h4><ul><li>The advantage of using this approach is that when the script tag is encountered then it will download the js file asynchronously along with HTML parsing but as soon as the file is downloaded it will stop the HTML parsing and start the execution of the js file.</li><li>Again, it arises the same problem as same as the above case but the difference with the above case was asynchronously downloading the js file. But, it is useful if we are calling API because it reduces the time for fetching the data. After all, this process can execute asynchronously.</li></ul><h4>3. &lt;script&gt; tag with defer attribute</h4><ul><li>The approach is the same as with the <em>async attribute </em>but the difference is when the js file is downloaded it will not start executing the file rather it will wait for the HTML parsing to complete and then after the execution of js will continue.</li></ul><p>I know that it is a bit confusing though theoretically, so I came up with the diagram shown below, which will help you to understand the things which is explained above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*P9DO2s42JTJU-EkP14EhQw.png" /></figure><p>Hope you understand the problem that I’m trying to explain and please provide your suggestions so that I can improve and prepare for more interesting topics.</p><p>Happy Learning📝, Happy coding 👨‍💻</p><p>Thank you</p><p>Bishal Kumar Saha</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a24d99c0453" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Demystifying Browser Rendering: A Deep Dive into HTML and CSS.]]></title>
            <link>https://medium.com/@kbishal922/demystifying-browser-rendering-a-deep-dive-into-html-and-css-c944a4503c09?source=rss-a7010c630858------2</link>
            <guid isPermaLink="false">https://medium.com/p/c944a4503c09</guid>
            <category><![CDATA[reflow]]></category>
            <category><![CDATA[render-tree]]></category>
            <category><![CDATA[html-css]]></category>
            <category><![CDATA[browsers]]></category>
            <category><![CDATA[dom]]></category>
            <dc:creator><![CDATA[Bishal kumar]]></dc:creator>
            <pubDate>Sun, 21 Jan 2024 12:51:39 GMT</pubDate>
            <atom:updated>2024-01-21T12:51:39.753Z</atom:updated>
            <content:encoded><![CDATA[<p>The purpose of writing this article is to explain how the inside of the browser works.</p><p>I know that very few people or resources are available on this topic, and I will try to explain it to the best of my knowledge. I would appreciate your feedback, whether it’s related to correcting any mistakes I may have made or anything else.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*6EpO8aHhLNh76wsG" /></figure><p>Ok, let&#39;s start 3…2…1…Go 🙂</p><h4><strong>What is a Web Browser?</strong></h4><p>A web browser is an application for accessing websites and the internet. For more details, please refer to this <a href="https://en.wikipedia.org/wiki/Web_browser">link</a>.</p><p>The block diagram of a web browser typically consists of the following components:</p><ul><li>User Interface: This component allows users to interact with the browser and navigate websites.</li><li>Rendering Engine: It interprets HTML, CSS, and JavaScript code to display web content correctly.</li><li>Networking: This component handles network requests and responses, allowing the browser to retrieve web resources.</li><li>Browser Engine: It coordinates the different components of the browser and manages their interactions.</li><li>JavaScript Engine: This engine interprets and executes JavaScript code on web pages.</li><li>Data Storage: It includes caches, cookies, and local storage, which store website data to improve performance and user experience.</li></ul><figure><img alt="Block diagram of web browser." src="https://cdn-images-1.medium.com/max/1024/0*Y41mW_HQJmajNGfV" /><figcaption>Block diagram of a web browser.</figcaption></figure><p>As we know, data is sent over the internet in packets sized in bytes. So, when we attempt to open an HTML or CSS file, the web browser reads the raw bytes of HTML or CSS. However, it can’t do anything with it, so the raw bytes of data must be converted into something understandable.</p><p><strong>Raw Bytes into Character Code.</strong></p><p>The browser uses the specified character encoding to decode the raw bytes into characters. This process is known as decoding or character set conversion. <strong>UTF-8</strong> is the most common character encoding used on the web because it supports a wide range of characters, including those from different languages and special symbols.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*bE8AynfXFC5EqEx0" /></figure><p><strong>Character to Token</strong></p><ul><li>Further, these characters are parsed into tokens and the process is called tokenization.</li><li>Tokenization is the process of breaking down the characters into meaningful chunks called tokens.</li><li>This token represents the different parts of the HTML parsing such as the <strong><em>start tag, end tag, context and attributes.</em></strong></li><li>Then, these tokens are converted into the nodes, it is an entity within a document object tree (<strong>DOM</strong>). The nodes are linked in a tree data structure known as the DOM.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/0*FUhGe5qm2irYbKSL" /></figure><ul><li>The DOM (Document Object Model) is the representation of relationship between the parent-child and its adjacent siblings etc.</li><li>Here is the final flow of the browser execute the HTML file.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XDVPdQfyJdDQXZoY" /></figure><h4><strong>But, what about the CSS file?</strong></h4><p>Ok so let us know how the CSS file is executed by the browser.</p><p>When the browser receives the raw bytes of the HTML and it request to fetch the <strong>‘styles.css’</strong> stylesheet linked.</p><p>&lt;!DOCTYPE html&gt;<br>&lt;html lang=”en”&gt;<br>&lt;head&gt;<br> &lt;meta charset=”UTF-8&quot;&gt;<br> &lt;meta name=”viewport” content=”width=device-width, initial-scale=1.0&quot;&gt;<br> &lt;title&gt;Chat Interface&lt;/title&gt;<br> &lt;link rel=”stylesheet” href=”styles.css”&gt;&lt;/link&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br> <br> &lt;script type=”text/javascript” src=”index.js”&gt;&lt;/script&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;</p><p><strong>From raw bytes to CSSOM</strong></p><ul><li>A similar process is initiated as same as the raw bytes of HTML, it happens parallel for both HTML and CSS.</li><li>The raw bytes are converted into characters, and then tokenized.</li><li>Nodes are formed and finally form a tree structure. But for HTML something called DOM (Document Object Model) similarly, for CSS it is called CSSOM (CSS Object Model).</li><li>The CSSOM tree tells us how the different elements should look when rendered. The tree structure allows the browser to start with the most general rule and refine the computed styles by going down the tree to more specific rules. The tree uses the cascading principle, combining inheritance and specificity to compute the styles for the different objects on the page.</li></ul><h4>The Render Tree</h4><p>The render tree is a data structure which is responsible for rendering the web pages. It is the combination of DOM and CSSOM. It includes only the elements that are going to be rendered on the page, taking into account styles and layout information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Kb2ywdOH5k0xYAM6" /></figure><h4>Layout</h4><p>Once the render tree is formed, the browser performs layout or reflow, determining the position and size of each render tree node based on its styling and the available space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/0*Vou0MbRJMoKhBH24" /></figure><h4>Paint</h4><p>This step is called painting, rasterizing, or repainting. Finally, now the browser knows which node to show or hide with all the CSS properties, so it will paint the pixels on the screen according to the information from the layout.</p><h3>But, wait what about the JS file? 🤔🤔🤔…</h3><p>So, we will look about the js file and how it renders and more about the &lt;script /&gt; tag with its attributes async and defer and all the cases in my next article.</p><p>Thank you for reaching out till here and would love to know your feedback. Please comment your suggestion so that I can improve it in my next article.</p><p>Bishal kumar Saha.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c944a4503c09" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>