<?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: Metin Abbaszade</title>
    <description>The latest articles on DEV Community by Metin Abbaszade (@metin_abbaszade_2cf1af1c4).</description>
    <link>https://dev.to/metin_abbaszade_2cf1af1c4</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%2F3300195%2F3c9eabbb-113e-4eef-9a2d-073270ea1cd5.jpg</url>
      <title>DEV Community: Metin Abbaszade</title>
      <link>https://dev.to/metin_abbaszade_2cf1af1c4</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/metin_abbaszade_2cf1af1c4"/>
    <language>en</language>
    <item>
      <title>10 CSS Optimization Tips to Make Your Website Faster</title>
      <dc:creator>Metin Abbaszade</dc:creator>
      <pubDate>Fri, 05 Sep 2025 07:42:23 +0000</pubDate>
      <link>https://dev.to/metin_abbaszade_2cf1af1c4/10-css-optimization-tips-to-make-your-website-faster-2g13</link>
      <guid>https://dev.to/metin_abbaszade_2cf1af1c4/10-css-optimization-tips-to-make-your-website-faster-2g13</guid>
      <description>&lt;p&gt;&lt;strong&gt;CSS is more than just a tool for styling.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When a user visits a webpage, the browser retrieves the site’s HTML structure along with its CSS. If your CSS is large, repetitive, or overly complex, it slows down rendering—like giving the browser a puzzle that takes longer to solve. Cleaner, simpler CSS helps web pages load faster and feel more responsive.&lt;/p&gt;

&lt;p&gt;Here are &lt;strong&gt;10 practical tips&lt;/strong&gt; developers use to optimize CSS for better performance.&lt;/p&gt;




&lt;h3&gt;
  
  
  1. Write Shorter CSS
&lt;/h3&gt;

&lt;p&gt;Apply the &lt;strong&gt;Don’t Repeat Yourself (DRY)&lt;/strong&gt; principle to CSS. Repeating properties across multiple selectors adds unnecessary code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: Repetitive CSS&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Optimized version: Group selectors&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#fff&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Use shorthand properties&lt;/strong&gt; wherever possible:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Before shorthand */&lt;/span&gt;
&lt;span class="nc"&gt;.same-sides&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* After shorthand */&lt;/span&gt;
&lt;span class="nc"&gt;.same-sides&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Shorthand properties reduce CSS file size and improve efficiency.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. Use Shallow CSS Selectors
&lt;/h3&gt;

&lt;p&gt;Avoid deeply nested selectors that make browsers work harder to find elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inefficient:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;header&lt;/span&gt; &lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="nt"&gt;ul&lt;/span&gt; &lt;span class="nt"&gt;li&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Efficient:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.nav-link&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Direct, concise selectors are faster for browsers to interpret and easier to maintain.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Segment CSS Code
&lt;/h3&gt;

&lt;p&gt;Breaking your CSS into component-specific or page-specific files improves maintainability and load performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before (single large CSS file):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Styles for the home page */&lt;/span&gt;
&lt;span class="nc"&gt;.homepage&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f0f0f0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Styles for the services page */&lt;/span&gt;
&lt;span class="nc"&gt;.services&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Styles for the contact page */&lt;/span&gt;
&lt;span class="nc"&gt;.contact&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#222&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After: Separate CSS files&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;homepage.css&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.homepage&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f0f0f0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&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;code&gt;services.css&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.services&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&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;code&gt;contact.css&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.contact&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#222&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Segmented CSS allows browsers to load only what is needed for a specific page.&lt;/p&gt;




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

&lt;p&gt;&lt;strong&gt;Minify CSS&lt;/strong&gt; to remove whitespace, comments, and unnecessary characters.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Original CSS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;header&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;nav&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Minified CSS:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;header&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="nt"&gt;nav&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;#444&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;&lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Minified CSS reduces file size and speeds up page loading.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Cache Your CSS
&lt;/h3&gt;

&lt;p&gt;Browsers can store CSS files locally after the first visit, so they don’t need to download them on every page load.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of caching:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduces load times for returning visitors&lt;/li&gt;
&lt;li&gt;Decreases server requests&lt;/li&gt;
&lt;li&gt;Improves overall performance&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to enable caching:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Configure server headers like &lt;code&gt;Cache-Control&lt;/code&gt;, &lt;code&gt;ETag&lt;/code&gt;, or &lt;code&gt;Last-Modified&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;cache busting&lt;/strong&gt; with version numbers or hashed filenames to ensure users receive updated CSS when necessary.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  6. Avoid Overusing the Universal Selector ()
&lt;/h3&gt;

&lt;p&gt;The universal selector targets &lt;strong&gt;all elements&lt;/strong&gt;, which can create performance issues and unintended styling conflicts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Universal selector misuse */&lt;/span&gt;
&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Arial&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Better approach:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;CSS resets&lt;/strong&gt; like &lt;code&gt;normalize.css&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Apply styles selectively (e.g., &lt;code&gt;html&lt;/code&gt;, &lt;code&gt;body&lt;/code&gt;, or specific element groups)&lt;/li&gt;
&lt;li&gt;Scope styles to components to avoid global overrides&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  7. Cut Down on Image HTTP Requests with CSS Sprites
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;CSS sprites&lt;/strong&gt; combine multiple small images into a single file. Use &lt;code&gt;background-position&lt;/code&gt; to display only the part of the image you need, reducing HTTP requests.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/css-sprites/?utm_source=chatgpt.com" rel="noopener noreferrer"&gt;Learn more about CSS sprites →&lt;/a&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  8. Preload Critical Assets
&lt;/h3&gt;

&lt;p&gt;Use &lt;code&gt;rel="preload"&lt;/code&gt; to fetch essential assets early—like CSS, fonts, and hero images—so they’re ready when the browser needs them.&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;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/css/main.css"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"style"&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;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/fonts/Inter-Regular.woff2"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"font"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"font/woff2"&lt;/span&gt; &lt;span class="na"&gt;crossorigin&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;rel=&lt;/span&gt;&lt;span class="s"&gt;"preload"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"/images/hero-banner.jpg"&lt;/span&gt; &lt;span class="na"&gt;as=&lt;/span&gt;&lt;span class="s"&gt;"image"&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 768px)"&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;&lt;strong&gt;Benefits of preloading:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSS loads faster, reducing render delays&lt;/li&gt;
&lt;li&gt;Fonts load early, preventing “flash of unstyled text”&lt;/li&gt;
&lt;li&gt;Key images display immediately, improving user experience&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  9. Remove Unnecessary Styles
&lt;/h3&gt;

&lt;p&gt;Unused CSS adds bytes and slows down page load.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="c"&gt;/* Unused styles */&lt;/span&gt;
&lt;span class="nc"&gt;.old-btn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;red&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.legacy-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="m"&gt;#ccc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How to Identify Unused CSS
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Use Chrome DevTools Coverage tab&lt;/strong&gt; – shows which CSS and JS rules are used while navigating your site. Keep in mind it only captures what’s loaded on the pages you visit.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Automated tools&lt;/strong&gt; – use &lt;strong&gt;PurgeCSS&lt;/strong&gt;, &lt;strong&gt;UnCSS&lt;/strong&gt;, or Tailwind’s purge option during your build process to remove unused selectors. Be careful: these tools may remove CSS needed for dynamic content or JavaScript-rendered elements if not configured properly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Visual regression testing&lt;/strong&gt; – tools like &lt;strong&gt;Percy&lt;/strong&gt; can compare screenshots across pages and states, helping ensure removing unused CSS doesn’t break your site.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Component-scoped CSS&lt;/strong&gt; – keeping styles modular and tied to components reduces the risk of accumulating unused CSS over time.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You have to know that no tool can guarantee 100% accuracy. Always verify on all pages, states, and screen sizes before deleting CSS, especially dynamic or rarely used selectors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How to clean CSS:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Manually delete unused selectors&lt;/li&gt;
&lt;li&gt;Use tools like &lt;strong&gt;PurgeCSS&lt;/strong&gt;, &lt;strong&gt;UnCSS&lt;/strong&gt;, or Tailwind’s purge option&lt;/li&gt;
&lt;li&gt;Keep styles modular and component-based&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  10. Optimize Element Changes with &lt;code&gt;will-change&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;will-change&lt;/code&gt; property hints to the browser which CSS properties are likely to change, allowing it to optimize rendering ahead of time.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;will-change&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;opacity&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Important considerations:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use only on elements that actually need it&lt;/li&gt;
&lt;li&gt;Overusing &lt;code&gt;will-change&lt;/code&gt; can increase memory usage and hurt performance&lt;/li&gt;
&lt;li&gt;Treat it as a &lt;strong&gt;last-resort tool&lt;/strong&gt; after optimizing animations and CSS&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;By following these &lt;strong&gt;10 tips&lt;/strong&gt;, you can make your CSS more efficient, reduce page load times, and create a smoother, faster experience for your users. Optimized CSS isn’t just cleaner—it’s faster and smarter.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>styling</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Understanding JavaScript Execution Contexts and Lexical Environments</title>
      <dc:creator>Metin Abbaszade</dc:creator>
      <pubDate>Mon, 25 Aug 2025 10:13:17 +0000</pubDate>
      <link>https://dev.to/metin_abbaszade_2cf1af1c4/understanding-javascript-execution-contexts-and-lexical-environments-5cp3</link>
      <guid>https://dev.to/metin_abbaszade_2cf1af1c4/understanding-javascript-execution-contexts-and-lexical-environments-5cp3</guid>
      <description>&lt;p&gt;Whenever JavaScript runs code, the engine needs a workspace to manage what’s happening. This workspace answers key questions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Which variables and functions are available? → Scope&lt;/li&gt;
&lt;li&gt;Where should I look if a variable isn’t here? → Scope Chain &lt;/li&gt;
&lt;li&gt;What is this right now? → Context Object&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This workspace is called an &lt;strong&gt;Execution Context&lt;/strong&gt;, and every execution context contains &lt;strong&gt;three main components&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Lexical Environment (LE) *&lt;/em&gt;→ Stores variables, functions, parameters, and references to outer environments.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variable Environment (VE)&lt;/strong&gt; → Internal storage mainly for var declarations and function declarations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;this&lt;/strong&gt; binding → Determines the current context object.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Types of Execution Contexts&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Global Execution Context (GEC)&lt;/strong&gt; → Created first when JS starts. Holds the Global Lexical Environment. Only one GEC exists.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Function Execution Context (FEC)&lt;/strong&gt; → Each function call creates a new Execution Context with its own Lexical Environment (local variables, arguments, inner functions). Its Outer points to the parent scope (where the function was defined).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Eval Execution Context (EEC)&lt;/strong&gt; → Created when using eval("..."). Runs code from a string. ⚠️ Rarely used and considered bad practice (security + performance issues).&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Example 1 – Global + Function Execution Context
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Global Execution Context
var name = "Metin";

function sayHello() {
  // Function Execution Context
  var greeting = "Hello";
  console.log(greeting + ", " + name);
}

sayHello();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now lets go analyze Step-by-Step:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Global Execution Context (GEC) created:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lexical Environment: { name: "Metin", sayHello: &amp;lt;function&amp;gt; }, Outer: null

Scope: name, sayHello

Scope Chain: Only global

this: window (browser) or global (Node.js)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Function Execution Context (FEC for sayHello) created:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lexical Environment: { greeting: "Hello" }, Outer → Global Lexical Environment

Scope: greeting

Scope Chain: Function scope → Global scope

this: undefined (strict mode)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Variable lookup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;greeting → found in FEC

name → not in FEC → check outer → Global LE → found "Metin"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Hello, Metin
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example 2 – Lexical Environment and Closures
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function outer() {
  let counter = 0;  // outer lexical environment

  function inner() {
    counter++;  // inner still "remembers" outer's variables
    console.log(counter);
  }

  return inner;
}

const fn = outer();  
fn(); // 1
fn(); // 2
fn(); // 3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step-by-Step&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Call outer() → FEC for outer created:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lexical Environment: { counter: 0, inner: &amp;lt;function&amp;gt; }, Outer → Global LE

Scope: counter, inner

Scope Chain: outer → global

this: undefined (strict mode)

inner returned → closure formed → retains reference to outer LE
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Call fn() → FEC for inner created:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Lexical Environment: {}, Outer → Lexical Environment of outer()

Scope: empty

Scope Chain: inner → outer → global

this: undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Variable lookup:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;counter → not in inner → outer LE → found → incremented
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output sequence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1
2
3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Don’t Just Drop a &lt;script&gt; — Here’s the Smarter Way</title>
      <dc:creator>Metin Abbaszade</dc:creator>
      <pubDate>Wed, 20 Aug 2025 11:58:52 +0000</pubDate>
      <link>https://dev.to/metin_abbaszade_2cf1af1c4/dont-just-drop-a-heres-the-smarter-way-30lc</link>
      <guid>https://dev.to/metin_abbaszade_2cf1af1c4/dont-just-drop-a-heres-the-smarter-way-30lc</guid>
      <description>&lt;h2&gt;
  
  
  Can you connect JavaScript to your HTML website?
&lt;/h2&gt;

&lt;p&gt;We’ve &lt;em&gt;all&lt;/em&gt; heard this question at least once.&lt;/p&gt;

&lt;p&gt;And the simple answer is: &lt;strong&gt;“Just add a &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; tag in your HTML file.”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But… &lt;strong&gt;where&lt;/strong&gt; you put it — and &lt;strong&gt;why&lt;/strong&gt; — makes a huge difference.&lt;/p&gt;

&lt;p&gt;When a browser receives a JS file from the server (with &lt;code&gt;Content-Type: application/javascript&lt;/code&gt;), it pauses rendering to &lt;strong&gt;execute the script&lt;/strong&gt;.&lt;br&gt;
That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If your script runs before the HTML is ready → your JS may fail.&lt;/li&gt;
&lt;li&gt;If it’s at the wrong place in the DOM → it can block the page from loading.
So placement is &lt;strong&gt;crucial&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Which brings us to the main question: &lt;strong&gt;how do we solve it&lt;/strong&gt;?&lt;br&gt;
✅ &lt;strong&gt;Place &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt; at the end of &lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt;&lt;/strong&gt; → ensures HTML is loaded before JS runs.&lt;br&gt;
But what if you &lt;em&gt;need&lt;/em&gt; the script earlier?&lt;/p&gt;

&lt;p&gt;If we add src (as defer/async won’t work with inline code), these attributes ensure smoother script loading.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;&lt;code&gt;defer&lt;/code&gt;&lt;/strong&gt; → downloads the JS while parsing HTML, but executes &lt;strong&gt;after HTML is fully loaded&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;✅ &lt;strong&gt;&lt;code&gt;async&lt;/code&gt;&lt;/strong&gt; → downloads the JS &lt;em&gt;and executes it immediately&lt;/em&gt; (without waiting for HTML). Useful for independent scripts like analytics, but risky if your code depends on DOM elements.&lt;/p&gt;

&lt;p&gt;Based on the final result, Linking JS to HTML is &lt;strong&gt;not just writing &lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It’s about controlling &lt;strong&gt;when and how&lt;/strong&gt; the script runs to avoid blocking your page or breaking your app.&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%2Fo2u7g93cbpzjo9lwk0nq.webp" 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%2Fo2u7g93cbpzjo9lwk0nq.webp" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>URL Yazıldıqda Hansı Proseslər İşləyir? (DNS, TCP, TLS, HTTP izahı ilə)</title>
      <dc:creator>Metin Abbaszade</dc:creator>
      <pubDate>Fri, 27 Jun 2025 13:20:03 +0000</pubDate>
      <link>https://dev.to/metin_abbaszade_2cf1af1c4/url-yazildiqda-hansi-proseslr-islyir-dns-tcp-tls-http-izahi-il-9g2</link>
      <guid>https://dev.to/metin_abbaszade_2cf1af1c4/url-yazildiqda-hansi-proseslr-islyir-dns-tcp-tls-http-izahi-il-9g2</guid>
      <description>&lt;p&gt;Müasir internet istifadəçisinin gündəlik etdiyi ən adi hərəkətlərdən biri brauzerdə bir vebsayta daxil olmaqdır. Məsələn, &lt;strong&gt;&lt;a href="http://example.com" rel="noopener noreferrer"&gt;http://example.com&lt;/a&gt;&lt;/strong&gt; yazdıqda səhnə arxasında çox sayda mühüm protokol və mexanizm işə düşür: DNS Lookup, TCP bağlantısı, TLS handshake (əgər HTTPS-dirsə), HTTP sorğusu və cavabı, sonda isə bağlantının bağlanması.&lt;/p&gt;

&lt;p&gt;Bu məqalədə bu prosesləri proqramçı və sistem səviyyəsində addım-addım izah edirik.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. DNS Lookup – Domen Adından IP ünvanına keçid&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;İlk mərhələdə brauzer ünvan çubuğuna yazılan domen adını (məsələn, example.com) müvafiq IP ünvanına çevirmək üçün DNS sisteminə sorğu göndərir.&lt;/p&gt;

&lt;p&gt;Məsələn:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;example.com  →  93.184.216.34
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Bu mərhələ başa çatmadan hansısa serverlə əlaqə qurmaq mümkün deyil. Əgər brauzerin &lt;strong&gt;cache-ində və ya sistem səviyyəsində (OS DNS cache, hosts faylı)&lt;/strong&gt; ünvan tapılmasa, DNS resolver-ə sorğu göndərilir.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. TCP Üçlü Salamlaşma (Three-Way Handshake)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Serverə məlumat göndərmək üçün əvvəlcə etibarlı bir əlaqə qurulmalıdır. Bu TCP protokolu vasitəsilə həyata keçirilir.&lt;/p&gt;

&lt;p&gt;Bağlantı belə qurulur:&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%2Fe2gxpjtiu1q7ex7yyqic.png" 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%2Fe2gxpjtiu1q7ex7yyqic.png" alt=" " width="800" height="800"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SYN (Synchronize) nədir&lt;/strong&gt; -&amp;gt; SYN bayrağı TCP bağlantısının qurulmasına başlamaq üçün göndərilir.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;SYN-ACK&lt;/strong&gt; -&amp;gt;Bu, serverin SYN-ə cavab olaraq göndərdiyi mesajdır və iki funksiyanı yerinə yetirir:&lt;br&gt;
1.&lt;strong&gt;ACK&lt;/strong&gt; ilə müştərinin SYN paketini qəbul etdiyini təsdiqləyir,&lt;br&gt;
2.&lt;strong&gt;SYN&lt;/strong&gt; ilə öz əlaqə istəyini bildirir (serverin öz sıra nömrəsi ilə).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Burada belə bir sual çıxır: &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Niyə 3 addım? 2 kifayət deyil? 🤔&lt;/strong&gt;&lt;br&gt;
Əgər üçüncü addım olmasa, əlaqə başlasa da, qarşılıqlı anlaşma olmaz — və TCP heç vaxt ‘təxmin’ əsasında işləməz.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;strong&gt;Portlar:&lt;/strong&gt;&lt;br&gt;
HTTP üçün: 80&lt;br&gt;
HTTPS üçün: 443&lt;br&gt;
Nəticədə hər iki tərəf arasında iki yönlü, ardıcıllıqla təmin olunmuş etibarlı əlaqə qurulur.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. (Əgər HTTPS-dirsə) TLS Handshake — Məlumatların Şifrələnməsi&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Əgər URL https:// ilə başlayırsa, TLS (əvvəllər isə SSL-dən istifadə edilirdi) şifrələmə protokolu tətbiq olunur. Bu mərhələdə müştəri və server simmetrik açarlarla şifrələnmiş əlaqə qurur.&lt;/p&gt;

&lt;p&gt;Əsas addımlar:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;ClientHello&lt;/strong&gt; → Müştəri öz TLS versiyalarını, dəstəklədiyi şifrələmə alqoritmlərini (cipher suites) və random (R₁) dəyərini təqdim edir.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ServerHello&lt;/strong&gt; → Server uyğun cipher seçir, öz random dəyərini (R₂) və sertifikat göndərir.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Key Exchange&lt;/strong&gt; → Müştəri tərəfindən yaradılmış gizli dəyər (pre-master secret) serverə göndərilir.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Session Key&lt;/strong&gt; → Hər iki tərəf eyni sessiya açarını hesablayır və təsdiqləyir.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Finished Messages&lt;/strong&gt; → Şifrələnmiş "finished" mesajları göndərilir.
➡️ Bu mərhələdən sonra bütün HTTP mesajları artıq TLS-in yaratdığı təhlükəsiz kanal içərisindən ötürülür.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. HTTP Sorğusu və Server Cavabı&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Bu mərhələdə brauzer serverə HTTP protokolu vasitəsilə konkret bir resurs (məsələn, /index.html) istədiyini bildirir.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. HTTP Request (Müştəri → Server)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /index.html HTTP/1.1
Host: example.com
User-Agent: MyBrowser/1.0
Accept: text/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;GET /index.html HTTP/1.1&lt;/strong&gt; -&amp;gt; Müştəri serverdən /index.html adlı resursu, HTTP/1.1 protokolu ilə, almaq üçün sorğu göndərir.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Host: example.com&lt;/strong&gt; -&amp;gt; Serverə hansı domenə aid resursun istənildiyini bildirir — eyni IP-də fərqli saytları ayırmaq üçün vacibdir.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;User-Agent: MyBrowser/1.0&lt;/strong&gt;-&amp;gt; Müştəri proqramının (brauzer, API, bot) özünü təqdim etmə üsuludur&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Accept: text/html&lt;/strong&gt; -&amp;gt; Müştərinin cavab olaraq hansı formatda məzmun istədiyini göstərir&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;B. Server emalı&lt;/strong&gt;&lt;br&gt;
Server:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URI-yə baxır (/index.html)&lt;/li&gt;
&lt;li&gt;Faylı və ya resursu tapır&lt;/li&gt;
&lt;li&gt;Status kodu və cavab başlıqları yaradır&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;C. HTTP Response (Server → Müştəri)&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 1024

&amp;lt;html&amp;gt;…&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;HTTP/1.1 200 OK&lt;/strong&gt; -&amp;gt; Server bildirir ki, HTTP sorğusu uğurla yerinə yetirildi və istənilən resurs tapıldı.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Content-Type: text/html; charset=utf-8&lt;/strong&gt; -&amp;gt; Cavabın HTML formatında olduğunu və simvolların UTF-8 kodlaşdırması ilə yazıldığını göstərir.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Content-Length: 1024&lt;/strong&gt; -&amp;gt; Serverin göndərdiyi məzmunun dəqiq uzunluğunu (baytla) göstərir ki, müştəri nə qədər data qəbul edəcəyini bilsin.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;…&lt;/strong&gt; -&amp;gt; Serverin cavab bədənindəki faktiki HTML məzmundur və brauzerdə görünəcək səhifəni təşkil edir.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bu cavabla birlikdə müştəriyə HTML məzmun çatdırılır və brauzer bu məzmunu parse edərək ekranda göstərir.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Bağlantının Bağlanması (Teardown)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;İş bitdikdən sonra, həm müştəri, həm server bağlantını təhlükəsiz və ardıcıllıqlı şəkildə bağlamalıdır.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A. TLS “close_notify” (yalnız HTTPS)&lt;/strong&gt;&lt;br&gt;
TLS şifrələməsi varsa, hər iki tərəf qarşı tərəfə “mətn ötürülməsi bitdi” mesajı göndərir:&lt;/p&gt;

&lt;p&gt;Client → Server: close_notify&lt;br&gt;
Server → Client: close_notify&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;B. TCP Dördlü Bağlanış (Four-Way Teardown)&lt;/strong&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%2F7w3mk2z308w0dgwaxora.png" 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%2F7w3mk2z308w0dgwaxora.png" alt=" " width="568" height="222"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;FIN (Finish)&lt;/strong&gt; -&amp;gt; FIN bayrağı TCP əlaqəsinin bir istiqamətdə bağlanmasını bildirir.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ACK (Acknowledgment)&lt;/strong&gt; -&amp;gt; ACK bayrağı göndərilən məlumatların və ya nəzarət mesajlarının uğurla alındığını təsdiq etmək üçün istifadə olunur.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bu addımlar tam TCP protokoluna uyğun, təhlükəsiz şəkildə əlaqənin sonlanması üçün vacibdir.&lt;/p&gt;

&lt;p&gt;Sonda isə belə bir sual yaranır:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Əgər "Three way handshake" zamanı SYN-ACK mümkündürsə, "Four-way Teardown" zamanı niyə FİN və ACK ayrı ayrı göndərilir?&lt;/strong&gt;&lt;br&gt;
Texniki olaraq FIN və ACK eyni paketdə göndərilə bilər, lakin TCP protokolu bu iki addımı məntiqi olaraq ayırır, çünki bu, təhlükəsizlik, axın nəzarəti və debugging üçün daha anlaşıqlıdır.&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>webdev</category>
      <category>webprotocols</category>
      <category>http</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
