<?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>Forem: Hongster</title>
    <description>The latest articles on Forem by Hongster (@hongster85).</description>
    <link>https://forem.com/hongster85</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%2F1600971%2Fe50d3487-f18f-404f-85ed-c5618bbd2777.jpeg</url>
      <title>Forem: Hongster</title>
      <link>https://forem.com/hongster85</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/hongster85"/>
    <language>en</language>
    <item>
      <title>Configuration Management : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Thu, 16 Apr 2026 14:00:59 +0000</pubDate>
      <link>https://forem.com/hongster85/configuration-management-understand-in-3-minutes-1n1j</link>
      <guid>https://forem.com/hongster85/configuration-management-understand-in-3-minutes-1n1j</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Problem Statement&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Configuration management&lt;/strong&gt; is the systematic practice of handling the settings, options, and environment variables that your software needs to run, without baking them directly into your code. You encounter this problem every time you need to run the same application in different places—like when your code works perfectly on your laptop with &lt;code&gt;localhost&lt;/code&gt; but crashes in production because the database password is hardcoded, or when a teammate can't run the project because they use a different API key. It’s the mess of manually changing files for each environment, which is tedious and a breeding ground for errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Core Explanation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;At its heart, configuration management separates the &lt;strong&gt;"what"&lt;/strong&gt; your app does from the &lt;strong&gt;"where"&lt;/strong&gt; and &lt;strong&gt;"how"&lt;/strong&gt; it runs. Instead of writing &lt;code&gt;database = "localhost"&lt;/code&gt; in your source files, you externalize those values. The system then loads the correct values based on the current context (e.g., development, testing, production).&lt;/p&gt;

&lt;p&gt;Think of it like a recipe. The source code is the list of instructions (sauté, bake, mix). The configuration is the list of ingredients and quantities. You wouldn't rewrite the entire recipe to double it; you just refer to a different ingredient list. Configuration management provides that separate, swappable list.&lt;/p&gt;

&lt;p&gt;It typically involves three key parts:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Configuration Sources:&lt;/strong&gt; The files, environment variables, or secret vaults where key-value pairs (like &lt;code&gt;DB_HOST&lt;/code&gt;, &lt;code&gt;API_URL&lt;/code&gt;) are stored.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;A Management Tool/Library:&lt;/strong&gt; The code or system that knows how to find, load, validate, and merge these values from different sources into a single, usable set for your application. Examples include simple &lt;code&gt;.env&lt;/code&gt; files with a library like &lt;code&gt;dotenv&lt;/code&gt;, or dedicated tools like &lt;strong&gt;Ansible&lt;/strong&gt;, &lt;strong&gt;Chef&lt;/strong&gt;, or cloud-native services.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Environment Isolation:&lt;/strong&gt; A clear rule that different environments (dev, staging, prod) get entirely different configuration data, even though the code remains identical.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical Context&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use configuration management when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  You work on a team (everyone needs consistent setups).&lt;/li&gt;
&lt;li&gt;  Your app runs in multiple environments (like your laptop, a CI server, and a production cloud).&lt;/li&gt;
&lt;li&gt;  You use sensitive data (API keys, passwords) that shouldn't be in your source code repository.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;You might &lt;em&gt;not&lt;/em&gt; need a formal system for:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  A tiny, one-person script that runs in only one place and has no secrets.&lt;/li&gt;
&lt;li&gt;  When the overhead of managing configuration files outweighs the benefit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common real-world use cases include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Database Connections:&lt;/strong&gt; Swapping connection strings between local, test, and production databases automatically.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Feature Flags:&lt;/strong&gt; Turning features on or off for specific users or environments without a code deployment.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Third-Party Service Config:&lt;/strong&gt; Pointing to different external API endpoints (e.g., a sandbox vs. a live payment gateway).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should care because it makes your application more &lt;strong&gt;portable, secure, and less error-prone&lt;/strong&gt;. It’s a foundational practice for reliable deployments and team collaboration.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Quick Example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s a simple before-and-after look at connecting to a database.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before (Hardcoded - The Problem):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# app.py
&lt;/span&gt;&lt;span class="n"&gt;db_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;localhost&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
&lt;span class="n"&gt;db_password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;supersecret123&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;  &lt;span class="c1"&gt;# Oops, now in git history!
&lt;/span&gt;&lt;span class="nf"&gt;connect_to_database&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db_host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db_password&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 (With Configuration Management - The Solution):&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# app.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;dotenv&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;load_dotenv&lt;/span&gt;

&lt;span class="nf"&gt;load_dotenv&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Loads values from a `.env` file
&lt;/span&gt;&lt;span class="n"&gt;db_host&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;DB_HOST&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;db_password&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getenv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;DB_PASSWORD&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Value is read from the environment
&lt;/span&gt;&lt;span class="nf"&gt;connect_to_database&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;db_host&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db_password&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight conf"&gt;&lt;code&gt;&lt;span class="c"&gt;# .env file (NOT committed to git)
&lt;/span&gt;&lt;span class="n"&gt;DB_HOST&lt;/span&gt;=&lt;span class="n"&gt;localhost&lt;/span&gt;
&lt;span class="n"&gt;DB_PASSWORD&lt;/span&gt;=&lt;span class="n"&gt;supersecret123&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example demonstrates the core principle: &lt;strong&gt;separating secret and environment-specific values from the application source code.&lt;/strong&gt; The code is now environment-agnostic and secure.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Takeaway&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The single most important rule is this: &lt;strong&gt;Your application's configuration should always be separate from its code, allowing you to deploy the same build artifact anywhere.&lt;/strong&gt; If you want to explore a simple, universal starting point, learn about the &lt;a href="https://12factor.net/config" rel="noopener noreferrer"&gt;12-Factor App methodology for configuration&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>configurationmanagement</category>
      <category>environmentisolation</category>
      <category>twelvefactorapp</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Lazy Loading : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Tue, 14 Apr 2026 14:01:03 +0000</pubDate>
      <link>https://forem.com/hongster85/lazy-loading-understand-in-3-minutes-b81</link>
      <guid>https://forem.com/hongster85/lazy-loading-understand-in-3-minutes-b81</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Problem Statement&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Lazy loading is a design pattern that delays the loading of a resource until the moment it's actually needed.&lt;/strong&gt; You encounter the need for it because loading everything upfront—whether it's images on a webpage, data from a database, or modules in your app—slows things down unnecessarily. Think about an e-commerce site with hundreds of product images; it's wasteful to download them all when a user might only see the first five. Or a massive web application that forces users to wait for the entire codebase to load before they can click "Login." Lazy loading solves this by shifting work until it's truly required, making your applications feel snappier and more efficient from the very first interaction.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Core Explanation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;At its heart, lazy loading works on a simple principle: don't do work until you have to. Instead of loading all resources during initial setup, you set up placeholders and load the real content on-demand when a specific &lt;strong&gt;trigger&lt;/strong&gt; occurs.&lt;/p&gt;

&lt;p&gt;Think of it like a restaurant with a huge menu. Instead of cooking every single dish in the morning (loading everything upfront), they prepare ingredients and start cooking a specific dish only when you order it (loading on demand). This saves time, energy, and resources.&lt;/p&gt;

&lt;p&gt;Here’s how the pattern typically breaks down:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The Placeholder:&lt;/strong&gt; Initially, you load a lightweight substitute. For an image, this is often a small, low-quality placeholder or an empty &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; with a fixed size. For code, it's a stub or a lightweight reference.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Trigger:&lt;/strong&gt; This is the event that signals the real resource is needed. Common triggers include: a user scrolling an image into the viewport, clicking a button to open a feature, or navigating to a specific route in a single-page application.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Loading Mechanism:&lt;/strong&gt; When the trigger fires, the system fetches and instantiates the real resource (the high-resolution image, the JavaScript module, the data chunk) and swaps it in for the placeholder. This is often handled by modern browser APIs like &lt;code&gt;IntersectionObserver&lt;/code&gt; for images or dynamic &lt;code&gt;import()&lt;/code&gt; for JavaScript.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The key components are the lightweight initial state, the event listener waiting for a signal, and the subsequent load-and-swap operation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical Context&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Use &lt;strong&gt;lazy loading&lt;/strong&gt; when you have large, non-critical resources that are not needed immediately for the page or application to function. It's perfect for:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Below-the-fold images and media&lt;/strong&gt; on content-heavy websites.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Components/modules/routes&lt;/strong&gt; in single-page applications (like React, Vue, or Angular apps) that aren't part of the initial login or home screen.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Data for secondary features&lt;/strong&gt;, such as comments on a blog post or details in an accordion panel.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Avoid lazy loading&lt;/strong&gt; for critical resources. Anything required for your &lt;strong&gt;Core Web Vitals&lt;/strong&gt;, especially the Largest Contentful Paint (LCP), should load immediately. Don't lazy load your main hero image, primary CSS, or the JavaScript needed for your initial render. You should also be cautious with content that will be needed almost instantly, as the slight loading delay can be jarring.&lt;/p&gt;

&lt;p&gt;You should care because this is one of the highest-impact patterns for improving perceived performance. It reduces initial load time, saves bandwidth for your users, and can significantly improve key performance metrics. If your app feels sluggish on first load or you're bundling massive amounts of code, lazy loading is likely your first tool to reach for.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Quick Example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Consider a webpage with a long list of article previews, each with an image. The traditional approach loads all 50 images at once. With lazy loading, you only load images as the user scrolls near them.&lt;/p&gt;

&lt;p&gt;Here’s a simplified look at the HTML change, using the native &lt;code&gt;loading="lazy"&lt;/code&gt; attribute for images:&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="c"&gt;&amp;lt;!-- Old Way: Loads immediately, regardless of position on page --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"article-image-1.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Article 1"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- Lazy Loaded: Loads only when near the viewport --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"article-image-1.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Article 1"&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&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;This single attribute tells the browser to defer loading the image until it's within a calculated distance of the viewport. The example demonstrates how a minimal change can offload significant work, allowing the browser to prioritize the images the user actually needs to see right now.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Takeaway&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The actionable insight is this: &lt;strong&gt;Treat loading as a strategic decision, not an inevitable upfront cost.&lt;/strong&gt; Defer any work that isn't essential for the first interaction to create a faster, more responsive experience. For a deep dive into implementation techniques, the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading" rel="noopener noreferrer"&gt;MDN Web Docs on Lazy Loading&lt;/a&gt; is an excellent next stop.&lt;/p&gt;

</description>
      <category>lazyloading</category>
      <category>performanceoptimization</category>
      <category>webdev</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Virtual DOM vs Real DOM : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Thu, 09 Apr 2026 14:00:36 +0000</pubDate>
      <link>https://forem.com/hongster85/virtual-dom-vs-real-dom-understand-in-3-minutes-4m8</link>
      <guid>https://forem.com/hongster85/virtual-dom-vs-real-dom-understand-in-3-minutes-4m8</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Problem Statement&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Understanding the &lt;strong&gt;Virtual DOM vs. Real DOM&lt;/strong&gt; means knowing why modern frameworks like React manage your web page's structure with a lightweight JavaScript copy, instead of directly manipulating the browser's built-in model. You encounter this concept when your app's UI feels slow during frequent updates—like in a live dashboard, a interactive form, or a fast-scrolling list—and you need a predictable, high-performance way to make those changes.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Core Explanation&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Think of the &lt;strong&gt;Real DOM&lt;/strong&gt; as the official, detailed blueprint of a building that the city hall maintains. Every time you want to move a wall (&lt;strong&gt;update the UI&lt;/strong&gt;), you must file paperwork to edit the official blueprint, a process that is slow and requires the whole document to be re-filed. In web terms, the Real DOM is the browser's live tree structure of your page; directly changing it is computationally expensive.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Virtual DOM&lt;/strong&gt; is your private, quick-to-edit sketch of that blueprint. Here’s how it works in three steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Virtual Copy:&lt;/strong&gt; Your framework (e.g., React) creates a lightweight JavaScript object that mirrors the Real DOM. This is the Virtual DOM.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Update the Sketch:&lt;/strong&gt; When your app's state changes, the framework creates a &lt;em&gt;new&lt;/em&gt; Virtual DOM object representing the desired UI.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Smart Comparison (Diffing):&lt;/strong&gt; The framework compares this new Virtual DOM snapshot with the previous one to pinpoint the &lt;strong&gt;exact&lt;/strong&gt; differences (e.g., one changed text label).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Efficient Update:&lt;/strong&gt; It then calculates the most efficient set of instructions and applies &lt;em&gt;only those necessary changes&lt;/em&gt; to the Real DOM.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The core principle is batching and minimizing direct, costly Real DOM operations. You describe your desired UI state, and the Virtual DOM system figures out the most efficient way to get there.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Practical Context&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;When you should care:&lt;/strong&gt;&lt;br&gt;
You are likely using the Virtual DOM pattern if you are building a &lt;strong&gt;complex, interactive Single-Page Application (SPA)&lt;/strong&gt; with frameworks like React, Vue, or Preact. It’s invaluable when you have frequent UI updates driven by state changes, as it automates performance optimization and provides a declarative, "state-to-UI" programming model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When it's less relevant:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  For &lt;strong&gt;static websites or simple pages&lt;/strong&gt; where JavaScript-driven updates are rare. Direct DOM manipulation or server-side rendering is simpler and sufficient.&lt;/li&gt;
&lt;li&gt;  In performance-critical scenarios where you need &lt;strong&gt;absolute, manual control&lt;/strong&gt; over updates (e.g., a 60fps game canvas). The Virtual DOM's diffing process has a tiny overhead, and for these edge cases, you might opt for a framework that compiles to direct DOM updates (like Svelte) or manual management.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why you should care:&lt;/strong&gt; It abstracts away the manual, error-prone task of DOM performance tuning. You focus on &lt;em&gt;what&lt;/em&gt; the UI should look like for a given state, not the step-by-step instructions to change it.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Quick Example&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Consider a simple component that displays a counter. With &lt;strong&gt;direct Real DOM manipulation&lt;/strong&gt;, you might write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Manual, imperative update&lt;/span&gt;
&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;counter&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;newCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With a &lt;strong&gt;Virtual DOM-based framework&lt;/strong&gt; (like React), you write &lt;em&gt;declarative&lt;/em&gt; code:&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="c1"&gt;// Declarative: Describe the UI for the current state&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"counter"&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;count&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&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;You only update the &lt;code&gt;count&lt;/code&gt; state variable. The framework's Virtual DOM engine detects that only the text content of this &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; changed. It then surgically updates &lt;em&gt;only&lt;/em&gt; that specific text node in the Real DOM, even if the rest of the component's HTML is more complex.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Key Takeaway&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The Virtual DOM is a &lt;strong&gt;performance optimization strategy&lt;/strong&gt; that lets you build dynamic UIs declaratively by batching and minimizing expensive browser updates. If you use React or similar frameworks, you're already leveraging it; understanding it helps you write better code and debug performance issues.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;For a deeper dive, check out the React team’s blog post on&lt;/em&gt; &lt;a href="https://reactjs.org/docs/reconciliation.html" rel="noopener noreferrer"&gt;&lt;em&gt;“Reconciliation.”&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>virtualdom</category>
      <category>realdom</category>
      <category>react</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>CSRF (Cross-Site Request Forgery) : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Tue, 07 Apr 2026 14:00:40 +0000</pubDate>
      <link>https://forem.com/hongster85/csrf-cross-site-request-forgery-understand-in-3-minutes-4hag</link>
      <guid>https://forem.com/hongster85/csrf-cross-site-request-forgery-understand-in-3-minutes-4hag</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Cross-Site Request Forgery (CSRF)&lt;/strong&gt; is an attack that tricks a user's browser into making an unwanted request to a website where they are already authenticated. You encounter this problem because modern web applications rely on browsers automatically sending stored credentials (like session cookies) with every request, which attackers can exploit to perform actions on a user's behalf without their consent. Imagine this: a user is logged into their bank in one tab, then clicks a link in a phishing email—that simple click could secretly trigger a request to transfer funds because the browser automatically attaches their valid bank session.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;A CSRF attack works by exploiting the trust a web application has in a user's browser. Here’s the simple breakdown of how it happens:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;The Setup:&lt;/strong&gt; A user logs into a legitimate site (e.g., &lt;code&gt;yourapp.com&lt;/code&gt;). The site issues a session cookie, which their browser stores and automatically sends with every subsequent request to &lt;code&gt;yourapp.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Trap:&lt;/strong&gt; The user, while still logged in, visits a malicious site (e.g., from a phishing email or a compromised ad). This site contains hidden, automatic code designed to trigger a request to &lt;code&gt;yourapp.com&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Forgery:&lt;/strong&gt; The user's browser, following the malicious site's instructions, makes a request to &lt;code&gt;yourapp.com&lt;/code&gt;. Crucially, it &lt;strong&gt;automatically includes the valid session cookie&lt;/strong&gt; from the legitimate login.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Result:&lt;/strong&gt; The target application (&lt;code&gt;yourapp.com&lt;/code&gt;) receives a request that looks perfectly legitimate—it has the correct session cookie—so it executes the action, like changing an email address or making a transaction, thinking the user intended it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it like a &lt;strong&gt;forged signature stamp&lt;/strong&gt;. Your browser holds the stamp (your session cookie). A CSRF attack is like a malicious actor secretly placing a document under your stamped hand—the application sees your valid stamp on the request and processes it, even though you never intended to sign that document.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;You need to defend against CSRF &lt;strong&gt;whenever your web application performs state-changing actions&lt;/strong&gt; (POST, PUT, PATCH, DELETE requests) that rely on authentication cookies or other browser-automatic credentials. This includes actions like updating a profile, changing a password, or processing a financial transaction.&lt;/p&gt;

&lt;p&gt;You generally do &lt;strong&gt;not&lt;/strong&gt; need CSRF protection for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Public, read-only operations (GET requests, though GET should never change state anyway).&lt;/li&gt;
&lt;li&gt;  Stateless APIs that use tokens like JWTs in the &lt;code&gt;Authorization&lt;/code&gt; header (since browsers don’t automatically attach these headers to cross-site requests).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should care because CSRF is a common and serious security flaw that can lead to compromised user accounts and data breaches. Modern frameworks (like Django, Rails, Spring Security, and Laravel) have built-in protections, but you must ensure they are properly enabled. If your app uses cookie-based sessions and has authenticated forms, CSRF defense is non-negotiable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Consider a simple, &lt;strong&gt;vulnerable&lt;/strong&gt; form in a banking app to transfer money:&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="c"&gt;&amp;lt;!-- Malicious site's code tricking a logged-in user --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;onload=&lt;/span&gt;&lt;span class="s"&gt;"document.forms[0].submit()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"https://yourbank.com/transfer"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"amount"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"1000"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"toAccount"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"ATTACKER_ACCOUNT"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the user is logged into &lt;code&gt;yourbank.com&lt;/code&gt;, visiting this malicious page would automatically submit the form and complete the transfer, as the browser sends the user's valid session cookie.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;protected&lt;/strong&gt; form includes a unique, secret CSRF token that the malicious site cannot guess or steal:&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="c"&gt;&amp;lt;!-- Your bank's legitimate form --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"https://yourbank.com/transfer"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"hidden"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"csrf_token"&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"a9b3f7e2c1d5"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"amount"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"text"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"toAccount"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Transfer&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server validates this token with every state-changing request. The attacker's forged request lacks the valid token and is rejected.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;The core defense is simple: &lt;strong&gt;for any state-changing request, verify that the user's browser intentionally sent the request, not just their credentials.&lt;/strong&gt; The standard method is to use a unique, unpredictable CSRF token issued by your server. For a deep dive on implementation, consult the &lt;a href="https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html" rel="noopener noreferrer"&gt;OWASP CSRF Prevention Cheat Sheet&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>csrf</category>
      <category>csrfattack</category>
      <category>websecurity</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Monitoring vs Observability : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Thu, 02 Apr 2026 14:00:54 +0000</pubDate>
      <link>https://forem.com/hongster85/monitoring-vs-observability-understand-in-3-minutes-1oeh</link>
      <guid>https://forem.com/hongster85/monitoring-vs-observability-understand-in-3-minutes-1oeh</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Understanding &lt;strong&gt;monitoring&lt;/strong&gt; vs &lt;strong&gt;observability&lt;/strong&gt; is about knowing the difference between watching for known problems and being able to explore and diagnose unknown issues in your systems. You encounter this problem when your dashboards are green but users are still complaining, or when you get a generic "high latency" alert and spend hours digging through logs to find the root cause—you have monitoring, but you lack true observability.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;Think of it like car maintenance. &lt;strong&gt;Monitoring&lt;/strong&gt; is your dashboard warning lights: they alert you when predefined thresholds are crossed, like the check-engine light for a known error code. &lt;strong&gt;Observability&lt;/strong&gt;, however, is having a detailed diagnostic system and a mechanic's toolkit; it lets you ask arbitrary questions ("why is it making that &lt;em&gt;new&lt;/em&gt; noise?") and explore data you didn't necessarily pre-select to find the answer.&lt;/p&gt;

&lt;p&gt;Here’s the breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Monitoring&lt;/strong&gt; tells you &lt;em&gt;that&lt;/em&gt; something is wrong. It's a set of predetermined metrics and logs you watch. You set up alerts for CPU usage, error rates, or latency spikes. It's reactive and best for known failure modes. The core question it answers is, "Is the system behaving as expected?"&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Observability&lt;/strong&gt; helps you understand &lt;em&gt;why&lt;/em&gt; something is wrong. It's a property of your system that allows you to understand its internal state from its external outputs. You achieve it by instrumenting your code to generate rich, correlated &lt;strong&gt;telemetry data&lt;/strong&gt;: metrics, logs, and &lt;strong&gt;distributed traces&lt;/strong&gt;. The core question it answers is, "What is happening, and why?"&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In short, monitoring is about watching a list of pre-defined gauges. Observability is about having the tools and data to debug any novel question that arises.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;You need robust &lt;strong&gt;monitoring&lt;/strong&gt; for all production systems to track system health and SLOs. It's your first line of defense. You invest in &lt;strong&gt;observability&lt;/strong&gt; when your system's complexity (like microservices, third-party APIs) makes failures unpredictable and hard to diagnose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to prioritize observability:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  When debugging requires stitching together events across multiple services.&lt;/li&gt;
&lt;li&gt;  When you need to understand user experience for specific flows, not just overall system health.&lt;/li&gt;
&lt;li&gt;  When "unknown-unknown" problems are causing significant outages or frustration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;When monitoring might suffice:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  For simple, monolithic applications with straightforward failure modes.&lt;/li&gt;
&lt;li&gt;  For tracking specific, well-understood business metrics (e.g., daily active users).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should care because as systems grow, the time spent debugging "what's wrong" can dominate development. Observability shifts you from fighting fires to understanding your system's behavior, leading to faster resolutions and more stable software.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Imagine a user reports that their payment failed.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;With &lt;strong&gt;monitoring&lt;/strong&gt;, you might see an alert that the &lt;code&gt;payment-service&lt;/code&gt; error rate is at 5%. You check the service logs and see a &lt;code&gt;DatabaseConnectionException&lt;/code&gt;. You've identified the symptom.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;With &lt;strong&gt;observability&lt;/strong&gt;, you examine a &lt;strong&gt;distributed trace&lt;/strong&gt; of that specific user's request. The trace shows the request journey: from the &lt;code&gt;web-api&lt;/code&gt;, to the &lt;code&gt;auth-service&lt;/code&gt;, to the &lt;code&gt;payment-service&lt;/code&gt;. You see that the &lt;code&gt;payment-service&lt;/code&gt; call is indeed failing, but the correlated logs and metrics reveal the &lt;em&gt;root cause&lt;/em&gt;: the &lt;code&gt;auth-service&lt;/code&gt; is timing out first, causing the payment service's database connection pool to be exhausted for subsequent requests.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The example shows how observability tools connect data points across services to pinpoint a root cause that was non-obvious from isolated monitoring.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Shift your mindset from just setting alerts (monitoring) to instrumenting your code to enable exploration (observability), especially as your systems become more complex.&lt;/strong&gt; For a deeper dive into the philosophy, read Charity Majors' post &lt;a href="https://www.honeycomb.io/blog/observability-is-a-many-splendored-thing" rel="noopener noreferrer"&gt;Observability is a Many-Splendored Thing&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>monitoring</category>
      <category>observability</category>
      <category>telemetrydata</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Rate Limiting : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Tue, 31 Mar 2026 14:00:44 +0000</pubDate>
      <link>https://forem.com/hongster85/rate-limiting-understand-in-3-minutes-14g</link>
      <guid>https://forem.com/hongster85/rate-limiting-understand-in-3-minutes-14g</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Rate limiting&lt;/strong&gt; is a technique that controls how many requests a user or system can make to a server within a specific timeframe. You encounter this problem directly when an API rejects your request with an error like "429 Too Many Requests" or "Rate Limit Exceeded." It affects you whether you're &lt;em&gt;consuming&lt;/em&gt; an API that's throttling your app's calls, or &lt;em&gt;building&lt;/em&gt; a service that's being overwhelmed by too much traffic, a buggy loop, or even a malicious attack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;Think of rate limiting like a &lt;strong&gt;leaky bucket&lt;/strong&gt;. A new, empty bucket can hold a certain number of tokens (your request &lt;strong&gt;allowance&lt;/strong&gt;). Every time you make a request, you take a token out. Tokens &lt;strong&gt;leak back in&lt;/strong&gt; at a steady rate (your &lt;strong&gt;replenishment rate&lt;/strong&gt;). If you try to make a request when the bucket is empty, you’re denied until a token leaks back in.&lt;/p&gt;

&lt;p&gt;Under the hood, a simple rate limiter checks three key things for each incoming request:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Who:&lt;/strong&gt; It identifies the requester using an API key, IP address, or user ID.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;How Many:&lt;/strong&gt; It checks a counter for that requester against a predefined limit (e.g., 100 requests).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;In What Time Window:&lt;/strong&gt; It enforces that limit within a specific period (e.g., per minute).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If the count is under the limit, the request proceeds and the counter increments. If the limit is hit, the server typically responds with an &lt;strong&gt;HTTP 429 status code&lt;/strong&gt; and often includes headers telling you when to try again.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;You should use rate limiting on any service where you need to &lt;strong&gt;ensure availability, protect resources, or enforce fair usage.&lt;/strong&gt; This is critical for public APIs, login endpoints, and expensive database operations.&lt;/p&gt;

&lt;p&gt;You might &lt;em&gt;not&lt;/em&gt; need to implement it for internal microservices communicating within a trusted network where traffic patterns are predictable and controlled, though it's still a good defensive practice.&lt;/p&gt;

&lt;p&gt;Common real-world use cases are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Protecting Third-Party APIs:&lt;/strong&gt; When using a service like Stripe or Twitter, you must respect their limits to avoid having your integration shut down.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Preventing Abuse:&lt;/strong&gt; Throttling login attempts or password resets to stop brute-force attacks.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Managing Infrastructure Load:&lt;/strong&gt; Ensuring one overly chatty client or a misconfigured job doesn't drown your database or application servers.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You should care because rate limiting is a fundamental tool for building &lt;strong&gt;resilient and secure systems.&lt;/strong&gt; It's not just about saying "no"—it's about saying "yes, reliably, to everyone."&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Imagine a login endpoint with a limit of 5 attempts per minute. The server tracks attempts by IP address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Pseudocode logic for the /login endpoint
&lt;/span&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;handle_login_request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ip_address&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;password&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;key&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;login_attempts:&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ip_address&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
    &lt;span class="n"&gt;current_attempts&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;incr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Increment counter
&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_attempts&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;redis&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;expire&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Set expiry on first attempt
&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_attempts&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;error&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Too many attempts. Try again in 60 seconds.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;429&lt;/span&gt;

    &lt;span class="c1"&gt;# ... proceed to validate password ...
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example shows the core pattern: &lt;strong&gt;increment, check, and reject.&lt;/strong&gt; The &lt;code&gt;429&lt;/code&gt; status code clearly communicates the limit to the client, and using a store like Redis with an expiry automates the "per minute" window.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Remember that &lt;strong&gt;rate limiting is a safety feature, not just a restriction&lt;/strong&gt;; it protects your system's stability and fairness for all users. For a deeper dive into algorithms and implementation, check out the &lt;a href="https://cloud.google.com/architecture/rate-limiting-strategies-techniques" rel="noopener noreferrer"&gt;Google Cloud Architecture Center's guide on rate limiting&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>ratelimiting</category>
      <category>leakybucket</category>
      <category>http429</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Webhooks : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Thu, 26 Mar 2026 14:00:46 +0000</pubDate>
      <link>https://forem.com/hongster85/webhooks-understand-in-3-minutes-3i0a</link>
      <guid>https://forem.com/hongster85/webhooks-understand-in-3-minutes-3i0a</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Webhooks are automated messages sent from apps when something happens.&lt;/strong&gt; They're the solution to the frustrating and inefficient "Are we there yet?" problem in software integrations. Instead of your application constantly asking (polling) another service for updates—like checking every 10 minutes for a new payment or a completed form submission—webhooks make the other service call you the instant the event occurs. Think of the last time you built a feature that needed real-time data from another platform; webhooks are how you get that data without wasting resources and introducing delay.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;At its core, a webhook is a simple callback over HTTP. It’s a way for App A (the provider) to notify your App B (the receiver) about an event by making an HTTP POST request to a URL you provide.&lt;/p&gt;

&lt;p&gt;Here’s how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;You Give a URL:&lt;/strong&gt; You register a public endpoint (e.g., &lt;code&gt;https://yourapp.com/webhooks/payment-processed&lt;/code&gt;) with a service that supports webhooks (like Stripe or GitHub).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;They Call It:&lt;/strong&gt; When a specified event happens in their system (e.g., &lt;code&gt;invoice.paid&lt;/code&gt; or &lt;code&gt;push&lt;/code&gt;), their server creates a payload of data about that event and sends it as an HTTP POST request to your endpoint.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;You Act on It:&lt;/strong&gt; Your server receives the request, verifies it’s legitimate, parses the data, and triggers the corresponding business logic in your app.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A simple analogy is &lt;strong&gt;"reverse API."&lt;/strong&gt; With a normal API, you call them. With a webhook, they call you. It's like asking a restaurant to text you when your table is ready (webhook) versus walking back to the host stand every two minutes to ask (polling).&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use webhooks when you need near real-time, event-driven updates from an external service.&lt;/strong&gt; They are ideal for automating workflows, syncing data between systems, and triggering immediate actions. Common use cases include processing payments (Stripe sends you a webhook on success), updating a database when a user signs up in another app, or triggering a CI/CD build when code is pushed to a repository (like GitHub Actions).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid webhooks&lt;/strong&gt; for low-volume events where a simple scheduled job is sufficient, or when the client application (like a mobile app) needs the update, as you can't reliably send a webhook to a device that might be offline. In those cases, polling or a persistent connection (like WebSockets) might be a better fit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You should care&lt;/strong&gt; because webhooks are the backbone of modern, decoupled, and efficient third-party integrations. They save server resources, reduce latency, and enable event-driven architectures.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Imagine you need to know when a customer's subscription renews via Stripe. Instead of polling their API, you'd set up a webhook endpoint:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// A simple Express.js endpoint for a Stripe 'customer.subscription.updated' webhook&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/webhooks/stripe&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;raw&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;application/json&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;}),&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Contains the subscription data&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;customer.subscription.updated&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;subscription&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;object&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// Update YOUR database with the new subscription status&lt;/span&gt;
    &lt;span class="nf"&gt;updateUserSubscription&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;subscription&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;json&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="na"&gt;received&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&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;This example demonstrates the passive nature of webhooks. Your code sits idle, waiting for Stripe to deliver the event. When they do, you immediately update your system's state, keeping it perfectly in sync.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Think of webhooks as a subscription service for events: you give a service your number (URL), and they call you only when there's news, eliminating wasteful polling and enabling real-time automation. For an excellent deep dive on implementation patterns, check out &lt;a href="https://webhooks.fyi" rel="noopener noreferrer"&gt;Webhooks.fyi&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>webhooks</category>
      <category>softwareintegrations</category>
      <category>eventdriven</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Static Site Generation (SSG) : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Tue, 24 Mar 2026 14:00:54 +0000</pubDate>
      <link>https://forem.com/hongster85/static-site-generation-ssg-understand-in-3-minutes-olj</link>
      <guid>https://forem.com/hongster85/static-site-generation-ssg-understand-in-3-minutes-olj</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Static Site Generation (SSG) is a web development technique where your entire website is built into a set of ready-to-serve HTML, CSS, and JavaScript files at deployment time.&lt;/strong&gt; You encounter this because building modern, fast websites often means wrestling with unnecessary complexity: you configure a server, manage a database, and write logic to render pages on every visit, even for content that rarely changes. This results in slower performance, higher hosting costs, and more points of failure, all for a simple blog or documentation site. SSG cuts through that complexity for the right projects.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;Think of SSG like &lt;strong&gt;meal prepping&lt;/strong&gt; for your website. Instead of cooking a fresh meal (generating a webpage) every time a visitor arrives, you cook all your meals in one big batch on Sunday (at build time) and store them in the fridge (a CDN). When guests come over, you just grab a pre-made plate and serve it instantly.&lt;/p&gt;

&lt;p&gt;Here’s how the "prep" process works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Content &amp;amp; Templates:&lt;/strong&gt; You provide your site content (often as Markdown files or from a Headless CMS) and page templates (using frameworks like Next.js, Gatsby, or Hugo).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The Build Process:&lt;/strong&gt; You run a build command. The SSG tool grabs all your content, injects it into the templates, and runs any necessary JavaScript.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Output:&lt;/strong&gt; The tool generates a folder containing every page of your site as a simple, static &lt;code&gt;.html&lt;/code&gt; file, alongside its assets (CSS, JS, images). There is &lt;strong&gt;no server-side code&lt;/strong&gt; in the output.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a user requests a page, the web server (or CDN) delivers the pre-built HTML file directly. No database queries, no template rendering, no waiting. This is why SSG sites are &lt;strong&gt;blazingly fast&lt;/strong&gt;, highly secure (no database to hack), and easily scalable (static files are trivial to serve globally via a CDN).&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use SSG when your site content is mostly static&lt;/strong&gt; and can be determined before a user visits. Perfect examples are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Marketing/Brochure Websites:&lt;/strong&gt; Company sites, portfolios, or event pages.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Content-Driven Sites:&lt;/strong&gt; Blogs, technical documentation, and knowledge bases.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Jamstack Applications:&lt;/strong&gt; Sites with dynamic &lt;em&gt;client-side&lt;/em&gt; interactivity (using React, etc.) but with pre-rendered content.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Avoid SSG when you need true, per-request dynamic content.&lt;/strong&gt; If every page view requires unique, real-time data from a database (like a user-specific dashboard, a live chat interface, or a constantly changing stock ticker), traditional server-side rendering (SSR) or client-side rendering is more appropriate. SSG is for publishing content, not for building complex web &lt;em&gt;applications&lt;/em&gt; with user-specific sessions on every page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Here's a simplified look at how a page is defined in Next.js (which supports SSG):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// This function runs at BUILD time to fetch data&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;getStaticProps&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;blogPost&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;getBlogPostFromMarkdownFile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello-world.md&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;blogPost&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// This component uses the pre-fetched data to render the page HTML at BUILD time&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="k"&gt;default&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;BlogPost&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;blogPost&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;article&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;h1&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;blogPost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/h1&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;      &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;blogPost&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/div&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&lt;/span&gt;    &lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="sr"&gt;/article&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;
&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;This example demonstrates the core SSG separation: &lt;code&gt;getStaticProps&lt;/code&gt; fetches data once during the build. The &lt;code&gt;BlogPost&lt;/code&gt; component then uses that data to generate the final, static HTML file (&lt;code&gt;hello-world.html&lt;/code&gt;). No data fetching happens when a user visits the page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;For content-centric websites, &lt;strong&gt;prioritize serving pre-built static files over generating pages on-demand to unlock maximal performance, security, and scalability with minimal operational overhead.&lt;/strong&gt; To dive deeper, explore the &lt;a href="https://jamstack.org/" rel="noopener noreferrer"&gt;Jamstack community guide&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>staticsitegeneration</category>
      <category>jamstack</category>
      <category>webperf</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Server-Side Rendering (SSR) : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Thu, 19 Mar 2026 14:01:04 +0000</pubDate>
      <link>https://forem.com/hongster85/server-side-rendering-ssr-understand-in-3-minutes-240d</link>
      <guid>https://forem.com/hongster85/server-side-rendering-ssr-understand-in-3-minutes-240d</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Server-Side Rendering (SSR) is a technique where a web page is rendered into HTML on the server and sent to the browser fully formed.&lt;/strong&gt; You encounter this problem when your sleek, modern JavaScript application loads in the browser and users stare at a blank screen or a loading spinner before they can interact with anything. You might also hear from your marketing team that your app's pages aren't showing up properly in search engine results, even though the content is there.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;With standard &lt;strong&gt;Client-Side Rendering (CSR)&lt;/strong&gt;, your browser downloads a bare-bones HTML file and a mountain of JavaScript. It then executes all that JavaScript to build the page's structure and content. This process takes time, leading to the "white screen of waiting."&lt;/p&gt;

&lt;p&gt;SSR flips this model. Here's how it works, step-by-step:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Initial Request:&lt;/strong&gt; When you navigate to a URL, your browser requests that page from the server.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Server-Side Processing:&lt;/strong&gt; The server doesn't send an empty shell. Instead, it runs the relevant application code (your React, Vue, etc.) &lt;strong&gt;on the server&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;HTML Generation:&lt;/strong&gt; The server executes the code to determine what the page should look like and &lt;strong&gt;renders it into a complete HTML document&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Delivery &amp;amp; Hydration:&lt;/strong&gt; The server sends this fully populated HTML file to the browser, which can &lt;strong&gt;paint it immediately&lt;/strong&gt;. Then, the browser downloads and executes the JavaScript bundle, which "takes over" the static page, attaching event handlers and making it interactive—a process called &lt;strong&gt;hydration&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Think of it like ordering at a restaurant.&lt;/strong&gt; CSR is when the waiter brings you all the raw ingredients and a recipe—you have to cook the meal yourself before eating. SSR is when the kitchen (the server) cooks the meal and delivers it ready to eat. You can start eating (seeing content) immediately, even before you get the utensils (interactivity).&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use SSR when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Search Engine Optimization (SEO) is critical.&lt;/strong&gt; Search engine crawlers can easily read the fully rendered HTML.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;You need fast initial page loads&lt;/strong&gt; for content-heavy public pages (blog posts, marketing sites, product pages).&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Users are on low-powered devices or slow networks&lt;/strong&gt;, as the server does the heavy lifting upfront.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Avoid SSR when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Your application is a &lt;strong&gt;highly interactive, authenticated dashboard&lt;/strong&gt; (like an admin panel or internal tool). The complexity of SSR often outweighs the benefits here.&lt;/li&gt;
&lt;li&gt;  You have &lt;strong&gt;very limited server resources&lt;/strong&gt;, as rendering on the server adds computational load.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Why should you care?&lt;/strong&gt; SSR directly impacts core business metrics: it improves user-perceived performance, increases SEO rankings, and can boost conversion rates for public-facing sites. If you're building anything users or search engines need to see quickly, SSR is on the table.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Imagine a React component for a product page:&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;ProductPage&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;img&lt;/span&gt; &lt;span class="na"&gt;src&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;imageUrl&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="na"&gt;alt&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt; &lt;span class="p"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="p"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="nt"&gt;div&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&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;In a CSR app, the browser receives an &lt;code&gt;&amp;lt;div id="root"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; placeholder and must fetch data and run React to fill it in.&lt;/p&gt;

&lt;p&gt;With SSR (using a Node.js server with Express), the server can render this component to a string &lt;em&gt;before&lt;/em&gt; sending the page:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/product/:id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetchProductData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;req&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;html&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;ReactDOMServer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;renderToString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;ProductPage&lt;/span&gt; &lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;product&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="sr"&gt;/&amp;gt;&lt;/span&gt;&lt;span class="se"&gt;)&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;  &lt;span class="nx"&gt;res&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`
    &amp;lt;html&amp;gt;
      &amp;lt;body&amp;gt;
        &amp;lt;div id="root"&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;html&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;&amp;lt;/div&amp;gt;
        &amp;lt;script src="/client-bundle.js"&amp;gt;&amp;lt;/script&amp;gt;
      &amp;lt;/body&amp;gt;
    &amp;lt;/html&amp;gt;
  `&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;The browser instantly receives the HTML containing the product's name, image, and description, displaying them before the &lt;code&gt;client-bundle.js&lt;/code&gt; even loads.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Prioritize &lt;strong&gt;SSR when your page's initial content is its primary value&lt;/strong&gt;, as it eliminates the rendering wait time for both users and search engines. For a practical, batteries-included way to implement SSR, explore a framework like &lt;strong&gt;Next.js&lt;/strong&gt;.&lt;/p&gt;

</description>
      <category>serversiderendering</category>
      <category>clientsiderendering</category>
      <category>seo</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Tree Shaking : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Tue, 17 Mar 2026 14:00:41 +0000</pubDate>
      <link>https://forem.com/hongster85/tree-shaking-understand-in-3-minutes-2h29</link>
      <guid>https://forem.com/hongster85/tree-shaking-understand-in-3-minutes-2h29</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;Tree shaking is a dead code elimination process that removes unused exports from your JavaScript bundle. You encounter this problem every time you import a massive library like Lodash or a UI framework just to use one or two functions—your production bundle becomes bloated with code that will never run, slowing down your application's load time and hurting user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;Think of your application's final bundled JavaScript file as a suitcase you're preparing for a trip. Without tree shaking, you'd pack your entire closet "just in case." With tree shaking, you analyze exactly what you need for the trip and pack only those items.&lt;/p&gt;

&lt;p&gt;Technically, modern bundlers like Webpack, Rollup, or Vite perform &lt;strong&gt;static analysis&lt;/strong&gt; during the build process. Here's how it works:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;It starts with ES6 module syntax (&lt;code&gt;import&lt;/code&gt;/&lt;code&gt;export&lt;/code&gt;).&lt;/strong&gt; The static structure of these modules (as opposed to CommonJS's dynamic &lt;code&gt;require()&lt;/code&gt;) allows the bundler to reliably trace dependencies.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The bundler maps your entire dependency graph.&lt;/strong&gt; It starts from your application's entry point and follows every &lt;code&gt;import&lt;/code&gt; statement, marking which exports are actually used.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;It eliminates "dead" or unused branches.&lt;/strong&gt; Any exported code that is never imported or reached is considered "dead." Like shaking a tree to see which leaves fall off, the bundler removes these unreachable exports from the final bundle.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;The result is a leaner, optimized production bundle.&lt;/strong&gt; Only the code that your application actually calls is included.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;You should rely on tree shaking &lt;strong&gt;automatically&lt;/strong&gt; as part of your standard production build process with a modern bundler. It's essential when using large, modular third-party libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When it's most valuable:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Importing from large utility libraries (e.g., using &lt;code&gt;lodash.get&lt;/code&gt; but not &lt;code&gt;lodash.set&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt; Using modern UI component libraries (e.g., Material-UI, React Bootstrap) where you import specific components.&lt;/li&gt;
&lt;li&gt; Building your own library or application with multiple internal modules, ensuring you don't ship unused code to users.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;When it might not apply or work:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  If you dynamically import modules (e.g., &lt;code&gt;import(someModule)&lt;/code&gt;), the bundler cannot statically analyze the dependency at build time.&lt;/li&gt;
&lt;li&gt;  If a library you're using is written with older CommonJS modules, it is often not "shakeable" unless the bundler can transform it.&lt;/li&gt;
&lt;li&gt;  It's a build-time optimization, so you don't manually "use" it in your code; you configure your tools to enable it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You should care because smaller bundles mean faster download, parsing, and execution times, directly improving your site's Core Web Vitals and user retention.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Imagine you need just the &lt;code&gt;capitalize&lt;/code&gt; function from a utility library.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Before Tree Shaking (or with a bad import):&lt;/strong&gt;&lt;br&gt;
&lt;/p&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;_&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// Imports the entire massive library&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;_&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// The bundle includes ALL of Lodash, even though you only use 'capitalize'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;After Tree Shaking (with a targeted import):&lt;/strong&gt;&lt;br&gt;
&lt;/p&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;capitalize&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;lodash-es&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// ES6 module version&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;capitalize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hello world&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="c1"&gt;// The bundler can now see you only use 'capitalize' and drops other exports.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example demonstrates how your import style directly enables the bundler to identify and safely remove thousands of lines of unused code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Tree shaking isn't something you write; it's a benefit you get by using ES6 modules (&lt;code&gt;import&lt;/code&gt;/&lt;code&gt;export&lt;/code&gt;) and a modern bundler, which automatically strips unused code to create the smallest possible production bundle. To dive deeper, consult the documentation for your specific bundler (e.g., &lt;a href="https://webpack.js.org/guides/tree-shaking/" rel="noopener noreferrer"&gt;Webpack's Guide to Tree Shaking&lt;/a&gt;).&lt;/p&gt;

</description>
      <category>treeshaking</category>
      <category>javascriptbundle</category>
      <category>deadcodeelimination</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Code Splitting : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Thu, 12 Mar 2026 14:01:04 +0000</pubDate>
      <link>https://forem.com/hongster85/code-splitting-understand-in-3-minutes-4j9d</link>
      <guid>https://forem.com/hongster85/code-splitting-understand-in-3-minutes-4j9d</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Code splitting&lt;/strong&gt; is a technique that breaks your application's final bundle into smaller, on-demand chunks. You encounter this problem because modern front-end development often results in shipping one massive JavaScript file to users—even if they only need a fraction of that code to view the initial page. This leads to painfully slow initial load times, especially on mobile networks, where users wait for code to download and parse before they can see or interact with anything.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;Think of your app's code like a massive delivery truck packed with every single item a store sells. A customer ordering just a pizza still has to wait for the entire truck to be unloaded. Code splitting is like splitting that inventory into smaller, separate trucks. You send only the pizza truck (the initial page code) immediately, and then dispatch the taco truck or the furniture van only when the customer specifically asks for those items.&lt;/p&gt;

&lt;p&gt;At its core, it works by changing how your code is &lt;strong&gt;bundled&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Static Splitting:&lt;/strong&gt; You manually define split points in your code, often at route boundaries. The bundler (like Webpack or Vite) creates separate files for each route.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Dynamic Splitting:&lt;/strong&gt; You use &lt;strong&gt;dynamic &lt;code&gt;import()&lt;/code&gt; statements&lt;/strong&gt; (which look like a function call) in your code. This tells the bundler, "Wrap this module and its dependencies in a separate chunk, and only fetch it when this line of code runs."&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Lazy Loading:&lt;/strong&gt; This is the runtime behavior enabled by splitting. The new code chunk is fetched over the network only at the moment it's actually needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The bundler handles the complex mapping, and your application loads the initial "critical" code much faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use code splitting when:&lt;/strong&gt; your main bundle size is noticeably impacting your &lt;strong&gt;First Contentful Paint&lt;/strong&gt; or &lt;strong&gt;Time to Interactive&lt;/strong&gt;. This is crucial for large, single-page applications (SPAs) with many routes or features, public-facing websites where every millisecond of load time impacts conversion, or when you include heavy third-party libraries.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid it or prioritize it lower for:&lt;/strong&gt; very small applications where the bundle size is already minimal, or for tiny, core utilities used everywhere—splitting them would add more network overhead than it saves.&lt;/p&gt;

&lt;p&gt;You should care because it directly impacts user experience and business metrics. Common use cases include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Route-based splitting:&lt;/strong&gt; Each major section of your app loads independently.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Component-based splitting:&lt;/strong&gt; For heavy, non-critical components (like a complex chart, a modal, or a rich text editor).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Library splitting:&lt;/strong&gt; Isolating large third-party libraries (e.g., a PDF renderer) to be loaded only on the pages that need them.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Here's a common pattern in a React application using dynamic imports for route-based splitting:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// BEFORE: All components bundled together&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;HomePage&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./HomePage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;HeavyDashboard&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./HeavyDashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;AdminPanel&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./AdminPanel&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// AFTER: Components are split into separate chunks&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;lazy&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HomePage&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./HomePage&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;HeavyDashboard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./HeavyDashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AdminPanel&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;lazy&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;import&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./AdminPanel&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;p&gt;With this change, the &lt;code&gt;HeavyDashboard&lt;/code&gt; component's code won't be in the initial download. It will only be fetched when the user navigates to the dashboard route. This shrinks the initial bundle and speeds up the app's first load.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Start splitting at the route level first—it's the highest-impact, lowest-effort win.&lt;/strong&gt; If you're using a modern framework like Next.js, Nuxt, or SvelteKit, this is often configured automatically. For a deeper dive, check out the &lt;a href="https://webpack.js.org/guides/code-splitting/" rel="noopener noreferrer"&gt;Webpack guide on code splitting&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>codesplitting</category>
      <category>javascriptbundling</category>
      <category>lazyloading</category>
      <category>abotwrotethis</category>
    </item>
    <item>
      <title>Feature Flags : Understand in 3 Minutes</title>
      <dc:creator>Hongster</dc:creator>
      <pubDate>Tue, 10 Mar 2026 14:00:51 +0000</pubDate>
      <link>https://forem.com/hongster85/feature-flags-understand-in-3-minutes-5gli</link>
      <guid>https://forem.com/hongster85/feature-flags-understand-in-3-minutes-5gli</guid>
      <description>&lt;h2&gt;
  
  
  Problem Statement
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;feature flag&lt;/strong&gt; is a simple conditional statement in your code that allows you to toggle a feature on or off without deploying new code. You encounter this problem because the traditional process of merging, testing, and deploying new features is risky and inflexible—it forces you to choose between releasing quickly and releasing safely. Imagine your new payment service has a bug in production; without a feature flag, you’d have to scramble to roll back the entire deployment. Or, picture wanting to test a new UI with just 10% of users; a simple on/off deployment makes that impossible.&lt;/p&gt;

&lt;h2&gt;
  
  
  Core Explanation
&lt;/h2&gt;

&lt;p&gt;Think of a feature flag as a light switch for your code. The switch itself is installed in the wall (your codebase), but the wiring that controls power to it comes from an external source. You can flip the switch on the wall anytime, but it only turns the light on if the external circuit is closed.&lt;/p&gt;

&lt;p&gt;Here’s how it works in practice:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;The "If" Statement:&lt;/strong&gt; You wrap new or changing code inside an &lt;code&gt;if&lt;/code&gt; statement that checks the state of a flag (e.g., &lt;code&gt;if (featureFlag.isEnabled("new-search-algorithm"))&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;The Flag Configuration:&lt;/strong&gt; The flag's state (on/off, or more complex rules) is managed &lt;em&gt;outside&lt;/em&gt; the application—in a configuration file, a database, or a specialized service (a &lt;strong&gt;feature management platform&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Dynamic Control:&lt;/strong&gt; Your app checks this external configuration at runtime. This means you can change a feature's behavior for specific users, regions, or percentages of traffic instantly, without a single line of code change or deployment.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The core mechanism is this separation of &lt;strong&gt;code deployment&lt;/strong&gt; from &lt;strong&gt;feature release&lt;/strong&gt;. You can ship the code wrapped in a flag, let it sit dormant in production, and then activate it when you're ready.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Context
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Use feature flags when:&lt;/strong&gt; you need to decouple deployment from release, perform canary releases or A/B tests, quickly disable a problematic feature, or enable features for specific users (like internal staff or beta testers).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Avoid feature flags for:&lt;/strong&gt; permanent configuration that never changes (use app config instead), or for toggling features at such a granular level that it creates complex, hard-to-maintain "spaghetti" logic in your code.&lt;/p&gt;

&lt;p&gt;You should care because this pattern directly tackles everyday pain points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  &lt;strong&gt;Reducing Risk:&lt;/strong&gt; Kill a buggy feature instantly by turning its flag off.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Enabling Continuous Delivery:&lt;/strong&gt; Merge code into mainline daily while hiding incomplete features from users.&lt;/li&gt;
&lt;li&gt;  &lt;strong&gt;Simplifying Testing:&lt;/strong&gt; Test features in production with real users before a full launch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you've ever dreaded a "big bang" release or needed a faster emergency shut-off valve, feature flags apply to your situation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick Example
&lt;/h2&gt;

&lt;p&gt;Here's a minimal code snippet for a new recommendation engine:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Check the flag state from your feature management service&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;featureFlagClient&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isEnabled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;new-recommendation-engine&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;recommendations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getNewRecommendations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// New, risky code&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;recommendations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;getLegacyRecommendations&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Old, stable code&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;What this demonstrates:&lt;/strong&gt; The new algorithm's code is live in production but completely inactive for everyone. From a management dashboard, you could enable it for just your team (&lt;code&gt;userId&lt;/code&gt; check) to test it. Later, you could roll it out to 5% of users (percentage rollout) with zero code changes. If metrics dip, one click turns it off for everyone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;The single most powerful concept to remember is that &lt;strong&gt;feature flags separate the act of deploying code from the act of releasing functionality&lt;/strong&gt;, giving you precise control and a safety net over what your users experience. For a deep dive into implementation patterns and cleanup strategies, check out the &lt;a href="https://launchdarkly.com/blog/feature-flag-best-practices/" rel="noopener noreferrer"&gt;Feature Flag Best Practices guide from LaunchDarkly&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>featureflags</category>
      <category>continuousdelivery</category>
      <category>riskreduction</category>
      <category>abotwrotethis</category>
    </item>
  </channel>
</rss>
