<?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: Nazar Hapak</title>
    <description>The latest articles on DEV Community by Nazar Hapak (@nazarhapak).</description>
    <link>https://dev.to/nazarhapak</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%2F1578667%2Fb2c561be-7444-4c0b-8378-bf52fe3d9de1.jpg</url>
      <title>DEV Community: Nazar Hapak</title>
      <link>https://dev.to/nazarhapak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nazarhapak"/>
    <language>en</language>
    <item>
      <title>Critical Rendering Path (CRP)</title>
      <dc:creator>Nazar Hapak</dc:creator>
      <pubDate>Wed, 12 Jun 2024 08:29:42 +0000</pubDate>
      <link>https://dev.to/nazarhapak/critical-rendering-path-crp-optimization-techniques-2kbd</link>
      <guid>https://dev.to/nazarhapak/critical-rendering-path-crp-optimization-techniques-2kbd</guid>
      <description>&lt;p&gt;Understanding Critical Rendering Path is crucial in web development, as it impacts performance and user experience of website. As a web developer you can optimize Critical Rendering Path for better perfomance and SEO rankings.&lt;/p&gt;

&lt;p&gt;In this article, we will look at basic terms of Critical Rendering Path, its sequence and techniques to optimize it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What exactly is CRP? 🤔
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Critical Rendering Path (CRP)&lt;/strong&gt; is a sequence of steps that the browser takes to convert HTML, CSS and JavaScript into pixels on the screen.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Terms 🧠
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Parsing&lt;/strong&gt; is a process of converting HTML and CSS into structures that the browser can understand and manipulate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rendering&lt;/strong&gt; is a process of converting DOM and CSSOM into pixels on the screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;DOM (Document Object Model)&lt;/strong&gt; is a tree-like structure representing the HTML content of a web page. Each element, attribute, and piece of text in the HTML document becomes a &lt;strong&gt;node&lt;/strong&gt; in this tree.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;CSSOM (CSS Object Model)&lt;/strong&gt; is a tree-like structure that represents the CSS styles of a web page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Render Tree&lt;/strong&gt; is combination of DOM and CSSOM. It contains only the nodes needed to render the page, including the visual information like styles and layout.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sequence in CRP 🚦
&lt;/h2&gt;

&lt;p&gt;Steps in rendering process:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;As browser receives &lt;strong&gt;first package&lt;/strong&gt; of &lt;em&gt;HTML file&lt;/em&gt;, it starts constructing the DOM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It continues the process of DOM construction and as soon as browser discovers a reference to CSS file (&lt;code&gt;&amp;lt;link rel="stylesheet"&amp;gt;&lt;/code&gt;) it sends HTTP request for CSS file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When it receives packages of &lt;em&gt;CSS file&lt;/em&gt;, it starts &lt;strong&gt;simultaneously&lt;/strong&gt; constructing the CSSOM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the browser counters reference to &lt;em&gt;JavaScript file&lt;/em&gt; (&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; element) it &lt;strong&gt;stops parsing&lt;/strong&gt; HTML and CSS, as JavaScript can directly manipulate DOM and CSSOM. Only after JavaScript finished downloading and executing, parsing process continues.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When browser encounters tags for external data like &lt;em&gt;images, videos, audio etc&lt;/em&gt;, it notes the locations of files but continues parsing the rest of the page. The browser can perform the initial paint of webpage even if the external data hasn't been fully loaded yet. (That's why u can see how images load even after main content has already appeared on screen).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DOM and CSSOM are combined to form the Render Tree, which represents what will be displayed on screen.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The browser makes the layout. It calculates the exact position and size of each visible element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The browser paints pixels on the screen and displays the webpage.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fzkuql8glztjho5307k5s.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fzkuql8glztjho5307k5s.JPG" alt="Critical Rendering Path" width="800" height="162"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note, that when content on a webpage changes dynamically (text changes color, hover animations etc) or additional content is loaded browser &lt;strong&gt;do not repaint the entire page&lt;/strong&gt;, instead it selectively updates parts of the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  CRP Optimization Techniques 💪
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Minimize Critical Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Ensure only the necessary resources are included in the critical path.&lt;/li&gt;
&lt;li&gt;Use minification tools (to remove blank space) and compression(.zip) to reduce the size of resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Optimize CSS Delivery
&lt;/h3&gt;

&lt;p&gt;Even though CSS simultaniously parsing itself along with HTML, rendering process won't start until both DOM and CSSOM are ready. So, it is a good idea to render important CSS first and defer everything else.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Inline important CSS content directly in the HTML.&lt;/li&gt;
&lt;li&gt;Load non-critical CSS asynchronously. &lt;code&gt;&amp;lt;link rel="stylesheet" href="style.css" media="print" onload="this.media='all'"&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Optimize JavaScript Delivery
&lt;/h3&gt;

&lt;p&gt;As you know for now, JavaScript blocks the parsing process of HTML and CSS as it can directly manipulate DOM and CSSOM. &lt;/p&gt;

&lt;p&gt;By default JavaScript behaviour, it stops parsing while it downloads and executes. But you can use &lt;code&gt;defer&lt;/code&gt; and &lt;code&gt;async&lt;/code&gt; attributes to change that.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Defering JavaScript ownloads it while HTML is parsing and executes it after it's done constructing DOM. &lt;code&gt;&amp;lt;script src="script.js" defer&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Downloading JavaScript asynchronously happens while HTML is parsing, but execution happens as soon as JavaScript file has finished downloading. &lt;code&gt;&amp;lt;script src="example.js" async&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many developers also put their scripts at the end of &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; element to ensure that they are loaded after HTML has been parsed.&lt;/p&gt;

&lt;p&gt;You can also inline important JavaScript directly in HTML just like CSS.&lt;/p&gt;

&lt;h3&gt;
  
  
  Use Preloading and Prefetching
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Preloading tells the browser to start fetching the file as soon as possible, before it is discovered in the document’s standard flow. This means the file is given a high priority. It doesn’t block the rendering process. &lt;code&gt;&amp;lt;link rel="preload" href="styles.css" as="style"&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Prefetching loads resources that might be needed in the near future. By fetching them in advance, browser can serve them from cache when they are actually needed. These files are given lower priority, which means that they are loaded after everything else. &lt;code&gt;&amp;lt;link rel="prefetch" href="about-us.html"&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Summary 📝
&lt;/h2&gt;

&lt;p&gt;Critical Rendering Path is a sequence of steps which browser takes to display web content and there are several techniques to optimize it. &lt;/p&gt;

&lt;p&gt;Thank you for reading, leave a comment if you want and stay cool!😎&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>performance</category>
      <category>javascript</category>
      <category>html</category>
    </item>
    <item>
      <title>How the Internet works? TCP/IP</title>
      <dc:creator>Nazar Hapak</dc:creator>
      <pubDate>Fri, 07 Jun 2024 10:45:25 +0000</pubDate>
      <link>https://dev.to/nazarhapak/how-the-internet-works-3g72</link>
      <guid>https://dev.to/nazarhapak/how-the-internet-works-3g72</guid>
      <description>&lt;p&gt;Understanding how the Internet works is a fundamental step for anyone diving into the world of web development. Whether you're a beginner starting out or an experienced developer refreshing your knowledge, knowing the basics of the Internet provides a strong foundation to build upon.&lt;/p&gt;

&lt;p&gt;In this article, we'll explore the core concepts of how the Internet operates, from the role of servers and clients to the intricacies of protocols and data transmission.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the Internet? 🌐
&lt;/h2&gt;

&lt;p&gt;The Internet is a &lt;strong&gt;large network of computers&lt;/strong&gt; that communicate with each other. The whole idea of the Internet is to ensure that computers stay connected, regardless of any disruption. This idea was implemented using &lt;strong&gt;decentralized&lt;/strong&gt; network. If one part of the network fails, data can be rerouted through other paths.&lt;/p&gt;

&lt;p&gt;Network is two or more computers connected either physically or wirelessly. The Internet consists of numerous smaller networks connected together. These networks communicate through a variety of &lt;strong&gt;protocols&lt;/strong&gt; and &lt;strong&gt;hardware&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Note, that computers that are connected to network are called &lt;strong&gt;host&lt;/strong&gt;. This term you can often see in tutorials and other posts. Network hosts that share or receive information are classified as &lt;strong&gt;server&lt;/strong&gt; or &lt;strong&gt;client&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The internet provides a wide range of services that facilitate communication, information access, commerce, entertainment, and more. For example: Email, World Wide Web(WWW), File Transfer.&lt;/p&gt;

&lt;p&gt;Note, that &lt;strong&gt;WWW is not the Internet&lt;/strong&gt;. World Wide Web (WWW) is a system of interconnected public webpages accessible through the Internet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Infrastructure of the Internet 📡
&lt;/h2&gt;

&lt;p&gt;How exactly computer from your home and any other computer can reach computers from all over the world? Here are some of components that make this possible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Routers and switches&lt;/strong&gt; are intermediary devices that manage the flow of data between and inside the networks. They ensure data packets find the most efficient path from the source to the destination.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Modem&lt;/strong&gt; is a computer hardware that transforms data from digital format to a format suitable for wireless transmission.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inernet Service Provider (ISP)&lt;/strong&gt; is a company that manages high-performance routers that are linked together and can also access other ISP's routers.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Submarine cables&lt;/strong&gt; are &lt;em&gt;fiber optic&lt;/em&gt; cables laid on the ocean floor to connect continents, enabling high-speed internet communication between regions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note, that fiber optic cables are used to transfer data over long distances, as they have much lower attenuation compared to copper cables. If you want to dive deeper in how the submarine cables transfer data between continents, I recommend to watch &lt;a href="https://www.youtube.com/watch?v=M7stcJ65_X4" rel="noopener noreferrer"&gt;this short video&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fgjgsxxsrx8xma1ou63pm.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fgjgsxxsrx8xma1ou63pm.JPG" alt="Infractructure of network in the Internet" width="800" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Interesting fact:&lt;/strong&gt; The data that is transferred through the Internet moves with speed that is close to speed of light, that is why you can download your videos so fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  Data transfering through the Internet 🗃️
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TCP/IP&lt;/strong&gt; - suite of protocols that defines how information moves from sender to receiver. It is commonly used in the Internet. The key component of TCP/IP is &lt;strong&gt;IP adress&lt;/strong&gt; (unique numerical adress assigned to every device on the Internet).&lt;/p&gt;

&lt;p&gt;TCP/IP can be understood in terms of layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Application Layer - defines how application uses the network (for example HTTP for communication between browser and web-server)&lt;/li&gt;
&lt;li&gt;﻿﻿﻿Transport Layer - creates and contains conversations between application processes on host (Can be either TCP or UDP)&lt;/li&gt;
&lt;li&gt;﻿﻿Network Layer - data is being broken into &lt;strong&gt;packages&lt;/strong&gt; in order to be delivered fast (uses IP headers so data from one host can find it's way to another host)&lt;/li&gt;
&lt;li&gt;Data Link Layer - delivery of traffic on a single portion of computer network&lt;/li&gt;
&lt;li&gt;Physical Layer (transmitting data through physical network connection)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Packages or packets&lt;/strong&gt;, are small units of data transmitted over a network. When large amounts of data need to be sent, they are broken down into smaller packets for efficient transmission.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example of communication between web browser and web server on the Internet using TCP/IP:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Client prepares HTTP request. (HTTP is the underlying protocol used for communication on the World Wide Web)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TCP Header&lt;/strong&gt; is added to the HTTP request, forming a &lt;em&gt;segment&lt;/em&gt;.&lt;/li&gt;
&lt;li&gt;Segment is broken into packages. &lt;strong&gt;IP Header&lt;/strong&gt;(mostly IP adresses of client and server) is added to each of packets. (When the packets arrive, host strips off IP Headers and reassembles the packets into original data).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ethernet Header&lt;/strong&gt; (Mostly MAC-adresses of computers in subnetwork) and Ethernet trailer are added to every packet. This creates Ethernet &lt;em&gt;frame&lt;/em&gt;
&lt;/li&gt;
&lt;li&gt;Data is transmitted through physical connections.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Frejt11o7axzq3u2fi2dw.JPG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Frejt11o7axzq3u2fi2dw.JPG" alt="Typical TCP/IP packet structure" width="800" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary 📝
&lt;/h2&gt;

&lt;p&gt;Internet is a complex network of interconnected computers that communicate through TCP/IP protocol.&lt;/p&gt;

&lt;p&gt;Thank you for reading, leave a comment if you want and never stop learning!💖&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>computerscience</category>
      <category>basics</category>
    </item>
  </channel>
</rss>
