<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Goutham JM</title>
    <description>The latest articles on DEV Community by Goutham JM (@gouthamjm).</description>
    <link>https://dev.to/gouthamjm</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F457960%2F7654f709-9aa2-4b58-b171-4ea7f13487cb.jpeg</url>
      <title>DEV Community: Goutham JM</title>
      <link>https://dev.to/gouthamjm</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gouthamjm"/>
    <language>en</language>
    <item>
      <title>Advanced Front End Developer Essentials - Part 2</title>
      <dc:creator>Goutham JM</dc:creator>
      <pubDate>Sun, 17 Oct 2021 03:31:00 +0000</pubDate>
      <link>https://dev.to/gouthamjm/advanced-front-end-developer-interview-essentials-part-2-41gm</link>
      <guid>https://dev.to/gouthamjm/advanced-front-end-developer-interview-essentials-part-2-41gm</guid>
      <description>&lt;p&gt;This post is a continuation of &lt;a href="https://dev.to/gouthamjm/advanced-fe-dev-interview-essentials-1-45ho"&gt;Advanced Front End Developer , Interview Essentials - Part 1&lt;/a&gt; ,if you haven't read it I strongly recommend you to go through the post where I have explained the CRP in detail&lt;/p&gt;

&lt;p&gt;Optimizing the Critical Rendering Path is very essential for performance of a site , and always keep in mind the below rule&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You cannot optimize something that you cannot measure&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  1.DOM Optimization
&lt;/h2&gt;

&lt;p&gt;You should stream HTML as fast as you can ,we can achieve that by these step's minification,compression and caching the HTML.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In which stage of CRP, Do you think will the page be rendered ?&lt;/strong&gt; &lt;br&gt;
It will be rendered when the render tree is constructed ,i.e. just after CSSOM has been constructed, and it will be the render blocking step , so it becomes crucial to optimize CSSOM&lt;/p&gt;
&lt;h2&gt;
  
  
  2.CSSOM Optimization
&lt;/h2&gt;

&lt;p&gt;As CSS is a render blocking resource,always keep your CSS lean, deliver it as quickly as possible, and we can use media types and queries to unblock rendering&lt;/p&gt;

&lt;p&gt;If we have some CSS styles that are only used under certain conditions, for example, when the page is being printed or being projected onto a large monitor,but you are viewing in a mobile ,then we can block rendering on the resources that are not used.&lt;/p&gt;

&lt;p&gt;CSS &lt;code&gt;media types&lt;/code&gt; and &lt;code&gt;media queries&lt;/code&gt; allow us to address these use cases,in the below example if we maintain a separate style sheet for different use cases , &lt;em&gt;Example&lt;/em&gt; : we may need to apply certain styling for print or in responsive site we can mention a specific width during which case only the style sheet must be imported&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"print.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"print"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"other.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 40em)"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When declaring your style sheet assets, pay close attention to the media type and queries; they greatly impact critical rendering path performance&lt;/p&gt;

&lt;h3&gt;
  
  
  Explanation:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt;    &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"style.css"&lt;/span&gt;    &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"all"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"portrait.css"&lt;/span&gt; &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"orientation:portrait"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;link&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"print.css"&lt;/span&gt;    &lt;span class="na"&gt;rel=&lt;/span&gt;&lt;span class="s"&gt;"stylesheet"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"print"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The first declaration is render blocking and matches in all conditions.&lt;/li&gt;
&lt;li&gt;The second declaration is also render blocking: "all" is the default type, so if you don’t specify any type, it’s implicitly set to "all". Hence, the first and second declarations are actually equivalent.&lt;/li&gt;
&lt;li&gt;The third declaration has a dynamic media query, which is evaluated when the page is loaded. Depending on the orientation of the device while the page is loading, portrait.css may or may not be render blocking.&lt;/li&gt;
&lt;li&gt;The last declaration is only applied when the page is being printed, so it is not render blocking when the page is first loaded in the browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Avoid CSS imports
&lt;/h3&gt;

&lt;p&gt;The CSS import (&lt;code&gt;@import&lt;/code&gt;) directive enables one stylesheet to import rules from another stylesheet file. However, avoid these directives because they introduce additional roundtrips into the critical path: the imported CSS resources are discovered only after the CSS stylesheet with the &lt;code&gt;@import&lt;/code&gt; rule itself is received and parsed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Put CSS in the document head
&lt;/h3&gt;

&lt;p&gt;Specify all CSS resources as early as possible within the HTML document so that the browser can discover the &lt;code&gt;&amp;lt;link&amp;gt;&lt;/code&gt; tags and dispatch the request for the CSS as soon as possible.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. JS Optimization
&lt;/h2&gt;

&lt;p&gt;JavaScript allows us to modify just about every aspect of the page: content, styling, and its response to user interaction . JavaScript can also block DOM construction and delay when the page is rendered. To deliver optimal performance, make your JavaScript async and eliminate any unnecessary JavaScript from the critical rendering path&lt;/p&gt;

&lt;p&gt;By default, JavaScript execution is "parser blocking": when the browser encounters a script in the document it must pause DOM construction, hand over control to the JavaScript runtime, and let the script execute before proceeding with DOM construction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let's take the below example where there is a style sheet as well as script that modify the  &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag , so will the text be rendered black or red , the answer to this lies in the order of the execution &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Page requests for HTML, and it will start building the DOM&lt;/li&gt;
&lt;li&gt;Then it will encounter style and request for CSS resources ,during this time CSS doesn't know whether the script will modify the CSS, so it will wait for  CSSOM to be constructed&lt;/li&gt;
&lt;li&gt;After CSSOM is constructed, then JS will be executed and will build the Render Tree&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;CSS blocks script as well as rendering page, so it becomes crucial  to optimize the CSS&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofq4xmg7o9zfdbyjf6n1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fofq4xmg7o9zfdbyjf6n1.png" alt="JS Optimization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution :&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;1.All JS code might not modify the DOM in such cases one way we can optimize JS it to load it after DOM has been loaded ,like below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight jsx"&gt;&lt;code&gt;   &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      function loadFunction() &lt;span class="si"&gt;{&lt;/span&gt;
        &lt;span class="nf"&gt;alert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Window is loaded&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="si"&gt;}&lt;/span&gt;
      window.onload = loadFunction();
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;script&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.Another way to solve this is to add &lt;code&gt;async&lt;/code&gt; attribute to the  &lt;code&gt;script&lt;/code&gt; tag , it does two things - it doesn't block DOM construction, and CSSOM construction , so basically what it does is it will allow JS not to block CRP &lt;br&gt;
3.There is also a &lt;code&gt;defer&lt;/code&gt; attribute that you can add to the script tag that tells the parser that the script should wait to execute until after the document is loaded&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary:
&lt;/h2&gt;

&lt;p&gt;So let's see what all the options we have to optimize the CRP&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Minification,Compression and Caching - HTML,CSS and JS&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce critical resources  - CSS media query ,avoid imports and use critical inline CSS , JS - with async or defer attribute&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Shorten CRP length , i.e. reduce the number of round trips for fetching resources , there are a ton of ways to optimize it based on different communication protocol,You can refer it &lt;a href="https://hpbn.co/" rel="noopener noreferrer"&gt;here&lt;/a&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Optimize the order in which the remaining critical resources are loaded: download all critical assets as early as possible to shorten the critical path length.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;There are other methods of optimizing a site ,in my next post I will discuss on how to achieve Fast Load time for your site&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;References:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developers.google.com/web/fundamentals/performance/critical-rendering-path" rel="noopener noreferrer"&gt;https://developers.google.com/web/fundamentals/performance/critical-rendering-path&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://classroom.udacity.com/courses/ud884" rel="noopener noreferrer"&gt;https://classroom.udacity.com/courses/ud884&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>career</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Advanced Front End Developer Essential - Part 1</title>
      <dc:creator>Goutham JM</dc:creator>
      <pubDate>Fri, 15 Oct 2021 03:45:37 +0000</pubDate>
      <link>https://dev.to/gouthamjm/advanced-fe-dev-interview-essentials-1-45ho</link>
      <guid>https://dev.to/gouthamjm/advanced-fe-dev-interview-essentials-1-45ho</guid>
      <description>&lt;h2&gt;
  
  
  Critical Path Rendering
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;It is the sequence of steps a browser undergoes to convert HTML,CSS and JS into pixels&lt;br&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Why do you need to understand it ?
&lt;/h3&gt;

&lt;p&gt;By optimizing the critical rendering path, we can significantly improve the time to first render of our pages. Further, understanding the critical rendering path also serves as a foundation for building well-performing interactive applications.&lt;/p&gt;

&lt;p&gt;Optimizing for performance is all about understanding what happens in these intermediate steps between receiving the HTML, CSS, and JavaScript bytes and the required processing to turn them into rendered pixels - that's the critical rendering path.&lt;/p&gt;

&lt;p&gt;The Critical Rendering Path undergoes 5 different steps ,as mentioned in the below image.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjsv2lkq8mfzwh7iubvo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjsv2lkq8mfzwh7iubvo.png" alt="Critical Rendering Path"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's try to understand each step one at a time&lt;/p&gt;

&lt;h3&gt;
  
  
  1.HTML to DOM
&lt;/h3&gt;

&lt;p&gt;When browser receives HTML , It needs to convert the HTML into Document Object Model ,It undergoes 4 small steps to construct the DOM Tree - Conversion , Tokenizing , Lexing and DOM construction&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf8gkeohr19vf43e6gfj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdf8gkeohr19vf43e6gfj.png" alt="HTML to DOM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Conversion:&lt;/strong&gt; The browser reads the raw bytes of HTML off the disk or network, and translates them to individual characters based on encoding (Ex : UTF-8).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tokenizing:&lt;/strong&gt; The browser converts strings of characters into distinct tokens— for example, "", ""—and other strings within angle brackets. Each token has a special meaning and its own set of rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lexing:&lt;/strong&gt; The emitted tokens are converted into "objects," which define their properties and rules.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;DOM construction:&lt;/strong&gt; The created objects are linked in a tree data structure that also captures the parent-child relationships.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : DOM Tree can be partially rendered and is considered to be render non-blocking&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4g2axp7ubh4kqzw55do.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj4g2axp7ubh4kqzw55do.png" alt="HTML to DOM Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2.CSSOM
&lt;/h3&gt;

&lt;p&gt;CSSOM undergo similar steps as HTML to DOM&lt;/p&gt;

&lt;p&gt;The CSS bytes are converted into characters, then tokens, then nodes, and finally they are linked into a tree structure known as the "CSS Object Model" (CSSOM)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sed2elktgppbmimqk16.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4sed2elktgppbmimqk16.png" alt="CSSOM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Any text contained within the &lt;span&gt; tag, that is placed within the body element, has a font size of 16 pixels and has red text—the font-size directive cascades down from the body to the span. However, if a span tag is the child of a paragraph (p) tag, then its contents are not displayed.&lt;/span&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F229xbsdt301qe4ged6jt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F229xbsdt301qe4ged6jt.png" alt="CSSOM Tree"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt; : CSSOM cannot be partially rendered and is considered to be render blocking  , we cannot render a partial CSSOM due to the reason that CSS might have different selectors with varied specificity due to which there will a good chance of rendering wrong style&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Rendering Tree
&lt;/h3&gt;

&lt;p&gt;The CSSOM and DOM trees are combined into a render tree, which is then used to compute the layout of each visible element and serves as an input to the paint process that renders the pixels to screen. Optimizing each of these steps is critical to achieving optimal rendering performance.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyoheczd6byasc6kagpi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqyoheczd6byasc6kagpi.png" alt="Render tree constuction"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Starting at the root of the DOM tree, traverse each visible node.

&lt;ul&gt;
&lt;li&gt;Some nodes are not visible (for example, script tags, meta tags, and so on), and are omitted since they are not reflected in the rendered output.&lt;/li&gt;
&lt;li&gt;Some nodes are hidden via CSS and are also omitted from the render tree; for example, the span node---in the example above---is missing from the render tree because we have an explicit rule that sets the "display: none" property on it.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;For each visible node, find the appropriate matching CSSOM rules and apply them.&lt;/li&gt;
&lt;li&gt;Emit visible nodes with content and their computed styles.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: As a brief aside, note that visibility: hidden is different from display: none. The former makes the element invisible, but the element still occupies space in the layout (that is, it's rendered as an empty box), whereas the latter (display: none) removes the element entirely from the render tree such that the element is invisible and is not part of the layout.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Layout
&lt;/h3&gt;

&lt;p&gt;Up to this point we've calculated which nodes should be visible and their computed styles, but we have not calculated their exact position and size within the viewport of the device---that's the "layout" stage, also known as "reflow."&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Explanation:&lt;/strong&gt;&lt;br&gt;
The width 100% of body is calculated based on the view port width , if in the meta tag we mention like below , the width will be screen size of device ex: Mobile will be 320px , so width:100% will be of &lt;code&gt;body&lt;/code&gt; 320px , &lt;code&gt;div&lt;/code&gt; as it is 50% of parent will be 160px and &lt;code&gt;p&lt;/code&gt; is 50% of 160px i.e. 80px&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;'viewport'&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;'width=device-width'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If viewport is not mentioned for device width , then it will be 980px by default &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwzgnt5wzxqq3qv08xvd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fiwzgnt5wzxqq3qv08xvd.png" alt="Layouting"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  5. Painting or Rasterizing
&lt;/h3&gt;

&lt;p&gt;This is the final stage, which converts each node in the render tree to actual pixels on the screen&lt;/p&gt;

&lt;p&gt;The time required to perform render tree construction, layout and paint varies based on the size of the document, the applied styles, and the device it is running on: the larger the document, the more work the browser has; the more complicated the styles, the more time taken for painting also (for example, a solid colour is "cheap" to paint, while a drop shadow is "expensive" to compute and render).&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary:
&lt;/h2&gt;

&lt;p&gt;A quick recap of the browser's steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Process HTML markup and build the DOM tree.&lt;/li&gt;
&lt;li&gt;Request CSS and JS resource (Not explained in this post)&lt;/li&gt;
&lt;li&gt;Process CSS markup and build the CSSOM tree.&lt;/li&gt;
&lt;li&gt;Execute JS (Not explained in this post)&lt;/li&gt;
&lt;li&gt;Combine the DOM and CSSOM into a render tree.&lt;/li&gt;
&lt;li&gt;Run layout on the render tree to compute geometry of each node.&lt;/li&gt;
&lt;li&gt;Paint the individual nodes to the screen.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I have left step 2 and 4 related to JS on purpose , I will explain those steps in my upcoming posts and I will update the link to those posts here , The second part of the post can be viewed &lt;a href="https://dev.to/gouthamjm/advanced-front-end-developer-interview-essentials-part-2-41gm"&gt;Advanced Front End Developer , Interview Essentials - Part 2&lt;br&gt;
&lt;/a&gt;, Happy to receive any constructive feedback&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;References:&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developers.google.com/web/fundamentals/performance/critical-rendering-path" rel="noopener noreferrer"&gt;&lt;em&gt;https://developers.google.com/web/fundamentals/performance/critical-rendering-path&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://classroom.udacity.com/courses/ud884" rel="noopener noreferrer"&gt;&lt;em&gt;https://classroom.udacity.com/courses/ud884&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/an-introduction-to-web-performance-and-the-critical-rendering-path-ce1fb5029494/" rel="noopener noreferrer"&gt;&lt;em&gt;https://www.freecodecamp.org/news/an-introduction-to-web-performance-and-the-critical-rendering-path-ce1fb5029494/&lt;/em&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>html</category>
      <category>css</category>
    </item>
    <item>
      <title>React 17 : Why it's so important ?</title>
      <dc:creator>Goutham JM</dc:creator>
      <pubDate>Wed, 09 Sep 2020 21:30:45 +0000</pubDate>
      <link>https://dev.to/gouthamjm/react-17-why-it-s-so-important-il6</link>
      <guid>https://dev.to/gouthamjm/react-17-why-it-s-so-important-il6</guid>
      <description>&lt;p&gt;&lt;a href="https://reactjs.org/blog/2020/08/10/react-v17-rc.html"&gt;React 17&lt;/a&gt; is out and it has been 2.5 years since the release of React 16, React 16.x included many new changes like Hooks,Context etc.,But the new React 17 has no new features but it's a right move they have done this time before going to that let's see some minor changes which has happened&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Changes to Event Delegation&lt;/strong&gt; :
React will no longer attach event handlers at the document level. Instead, it will attach them to the root DOM container into which your React tree is rendered &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jywQewQU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://reactjs.org/static/bb4b10114882a50090b8ff61b3c4d0fd/31868/react_17_delegation.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jywQewQU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://reactjs.org/static/bb4b10114882a50090b8ff61b3c4d0fd/31868/react_17_delegation.png" alt="" width="800" height="619"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why this is important ?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ol&gt;
&lt;li&gt;It will make it easier to use React with other JS frameworks.&lt;/li&gt;
&lt;li&gt;It is safer to use a React tree managed by one version inside a tree managed by a different React version.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No React import&lt;/strong&gt; : 
If you were using Create React App boiler plate(cra) or npm to download react and you would be importing React in every jsx or js code ,now it is no longer required
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;onScroll Bubbling Event&lt;/strong&gt; : In React previous version there was a lesser known bug , the parent element used to capture the scroll event of the children this was causing an issue in using the scroll event listener, this has been fixed now&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No Event Pooling&lt;/strong&gt; : For those who don't know what Event Pooling is: The event handlers that we have in any react-app are actually passed instances of SyntheticEvent(A Wrapper for native browser events so that they have consistent properties across different browsers).&lt;br&gt;&lt;br&gt;
Whenever an event is triggered, it takes an instance from the pool and populates its properties and reuses it. When the event handler has finished running, all properties will be nullified and the synthetic event instance is released back into the pool.&lt;br&gt;&lt;br&gt;
This was build to actually increase the performance but It didn't improve the performance in the modern browsers and also it used to confuse the developers so they decided to remove it.&lt;br&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Effect Cleanup Timing&lt;/strong&gt; :The useEffect hook in React 16 runs &lt;strong&gt;asynchronously&lt;/strong&gt; but the cleanup which we used , like this used to run &lt;strong&gt;synchronously&lt;/strong&gt; this introduced an issue , Example: If you called an Api or An Animation and before the action is complete if the component gets unmounted&lt;br&gt;&lt;br&gt;
Now it is no longer an issue as it runs asynchronously even if the component is unmounted , the cleanup will happen , resulting in better performance&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;useEffect(() =&amp;gt; {
    event.subscribe()
    return function cleanup() {
        event.unsubscribe()
    }
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might be confused are these not features ?,these are more of changes internally and bug fixes good to know ,but this release is a right move, now is the right time to migrate your old react projects from class to functions based on hooks or implement context , this will give enough time for both business and developers to catch up to the fast pace in which react was moving.&lt;br&gt;
If you find any new feature , please put it in the comments&lt;/p&gt;

&lt;p&gt;I am a Full Stack JS Developer,This is my first article in Dev, any suggestions or constructive feedback on the article are welcome &lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>reactnative</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
