<?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: Shubham Gupta</title>
    <description>The latest articles on Forem by Shubham Gupta (@shubham_gupta_decf96a6ab2).</description>
    <link>https://forem.com/shubham_gupta_decf96a6ab2</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%2F3726800%2F57cb3ab9-8aa2-4b48-8fd1-27c81332630d.jpg</url>
      <title>Forem: Shubham Gupta</title>
      <link>https://forem.com/shubham_gupta_decf96a6ab2</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/shubham_gupta_decf96a6ab2"/>
    <language>en</language>
    <item>
      <title>Things Nobody Tells You About Building Chrome Extensions</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Mon, 18 May 2026 19:01:37 +0000</pubDate>
      <link>https://forem.com/shubham_gupta_decf96a6ab2/things-nobody-tells-you-about-building-chrome-extensions-3i09</link>
      <guid>https://forem.com/shubham_gupta_decf96a6ab2/things-nobody-tells-you-about-building-chrome-extensions-3i09</guid>
      <description>&lt;p&gt;When I started learning Chrome extension development, I thought it would be easy.&lt;/p&gt;

&lt;p&gt;I already knew:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So I assumed:&lt;br&gt;
“Building a browser extension should take only a few hours.”&lt;/p&gt;

&lt;p&gt;I was wrong. 😅&lt;/p&gt;

&lt;p&gt;Chrome extensions work very differently from normal web applications.&lt;/p&gt;

&lt;p&gt;You need to understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;manifests,&lt;/li&gt;
&lt;li&gt;permissions,&lt;/li&gt;
&lt;li&gt;content scripts,&lt;/li&gt;
&lt;li&gt;service workers,&lt;/li&gt;
&lt;li&gt;browser security,&lt;/li&gt;
&lt;li&gt;an extension architecture.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In this article, I’ll explain the things that confused me the most while building my first Chrome extension.&lt;/p&gt;

&lt;p&gt;If you’re a beginner, this guide may save you many hours.&lt;/p&gt;


&lt;h1&gt;
  
  
  First, What Is a Chrome Extension?
&lt;/h1&gt;

&lt;p&gt;A Chrome extension is a small application that runs inside the browser.&lt;/p&gt;

&lt;p&gt;Extensions can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;modify webpages,&lt;/li&gt;
&lt;li&gt;automate tasks,&lt;/li&gt;
&lt;li&gt;save notes,&lt;/li&gt;
&lt;li&gt;block ads,&lt;/li&gt;
&lt;li&gt;use AI,&lt;/li&gt;
&lt;li&gt;summarize content,&lt;/li&gt;
&lt;li&gt;and much more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Grammarly&lt;/li&gt;
&lt;li&gt;Honey&lt;/li&gt;
&lt;li&gt;Dark Reader&lt;/li&gt;
&lt;li&gt;Momentum&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of these are browser extensions.&lt;/p&gt;


&lt;h1&gt;
  
  
  The Most Important File: manifest.json
&lt;/h1&gt;

&lt;p&gt;The first confusing thing in Chrome extension development is the &lt;code&gt;manifest.json&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Think of it like the brain of your extension.&lt;/p&gt;

&lt;p&gt;This file tells Chrome:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;your extension name,&lt;/li&gt;
&lt;li&gt;version,&lt;/li&gt;
&lt;li&gt;permissions,&lt;/li&gt;
&lt;li&gt;scripts,&lt;/li&gt;
&lt;li&gt;icons,&lt;/li&gt;
&lt;li&gt;popup pages,&lt;/li&gt;
&lt;li&gt;and features.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without this file, your extension will not work.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"manifest_version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"My First Extension"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"version"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"1.0"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"action"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"default_popup"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"popup.html"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first this looks simple.&lt;/p&gt;

&lt;p&gt;But as your extension grows, this file becomes very important.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is Manifest Version 3?
&lt;/h1&gt;

&lt;p&gt;Most old tutorials use Manifest V2.&lt;/p&gt;

&lt;p&gt;But Chrome now uses Manifest V3 (MV3).&lt;/p&gt;

&lt;p&gt;This changes many things.&lt;/p&gt;

&lt;p&gt;The biggest change:&lt;br&gt;
background scripts are replaced with service workers.&lt;/p&gt;

&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;extensions do not stay active all the time,&lt;/li&gt;
&lt;li&gt;Chrome stops them when inactive,&lt;/li&gt;
&lt;li&gt;and they restart only when needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As a beginner, this confused me a lot because I expected my extension to behave like a normal application.&lt;/p&gt;


&lt;h1&gt;
  
  
  Understanding Extension Parts
&lt;/h1&gt;

&lt;p&gt;A Chrome extension usually has 4 main parts.&lt;/p&gt;


&lt;h2&gt;
  
  
  1. Popup
&lt;/h2&gt;

&lt;p&gt;This is the small UI that opens when users click the extension icon.&lt;/p&gt;

&lt;p&gt;Usually built using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTML&lt;/li&gt;
&lt;li&gt;CSS&lt;/li&gt;
&lt;li&gt;JavaScript&lt;/li&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Todo popup&lt;/li&gt;
&lt;li&gt;AI assistant popup&lt;/li&gt;
&lt;li&gt;Note-taking UI&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  2. Content Script
&lt;/h2&gt;

&lt;p&gt;This script runs inside websites.&lt;/p&gt;

&lt;p&gt;It can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;read webpage content,&lt;/li&gt;
&lt;li&gt;modify the DOM,&lt;/li&gt;
&lt;li&gt;inject buttons,&lt;/li&gt;
&lt;li&gt;extract text.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
A YouTube summarizer extension reads video titles and transcripts using content scripts.&lt;/p&gt;

&lt;p&gt;This was one of the hardest concepts for me initially.&lt;/p&gt;


&lt;h2&gt;
  
  
  3. Background Service Worker
&lt;/h2&gt;

&lt;p&gt;This handles background logic.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;listening for browser events,&lt;/li&gt;
&lt;li&gt;handling API calls,&lt;/li&gt;
&lt;li&gt;managing notifications.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But unlike normal apps:&lt;br&gt;
it does not stay alive forever.&lt;/p&gt;

&lt;p&gt;This behavior creates many beginner bugs.&lt;/p&gt;


&lt;h2&gt;
  
  
  4. Storage
&lt;/h2&gt;

&lt;p&gt;Extensions can save data using Chrome storage APIs.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;saved notes,&lt;/li&gt;
&lt;li&gt;settings,&lt;/li&gt;
&lt;li&gt;AI prompts,&lt;/li&gt;
&lt;li&gt;authentication tokens.&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  Permissions Are Extremely Important
&lt;/h1&gt;

&lt;p&gt;Extensions often ask for permissions like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;tabs&lt;/li&gt;
&lt;li&gt;storage&lt;/li&gt;
&lt;li&gt;activeTab&lt;/li&gt;
&lt;li&gt;scripting&lt;/li&gt;
&lt;/ul&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"permissions"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"storage"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"activeTab"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first I added many permissions without thinking.&lt;/p&gt;

&lt;p&gt;But I later realized:&lt;br&gt;
too many permissions make users suspicious.&lt;/p&gt;

&lt;p&gt;Good extensions request only what they truly need.&lt;/p&gt;




&lt;h1&gt;
  
  
  Debugging Chrome Extensions Is Weird
&lt;/h1&gt;

&lt;p&gt;Debugging normal apps is simple.&lt;/p&gt;

&lt;p&gt;Chrome extensions are different because each part has separate DevTools.&lt;/p&gt;

&lt;p&gt;You may debug:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;popup console,&lt;/li&gt;
&lt;li&gt;content script console,&lt;/li&gt;
&lt;li&gt;background worker console.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wasted a lot of time checking the wrong console 😅&lt;/p&gt;




&lt;h1&gt;
  
  
  Content Scripts Are Isolated
&lt;/h1&gt;

&lt;p&gt;One thing nobody explains properly:&lt;/p&gt;

&lt;p&gt;Content scripts run inside webpages…&lt;br&gt;
but they are still isolated from the page itself.&lt;/p&gt;

&lt;p&gt;This means:&lt;br&gt;
some variables are inaccessible,&lt;br&gt;
and some scripts behave differently.&lt;/p&gt;

&lt;p&gt;At first this feels very confusing.&lt;/p&gt;




&lt;h1&gt;
  
  
  Chrome Security Is Strict
&lt;/h1&gt;

&lt;p&gt;Chrome blocks many unsafe operations.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;inline JavaScript,&lt;/li&gt;
&lt;li&gt;unsafe eval(),&lt;/li&gt;
&lt;li&gt;random external scripts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This security system is called CSP (Content Security Policy).&lt;/p&gt;

&lt;p&gt;Many libraries that work in React apps may fail inside extensions because of CSP restrictions.&lt;/p&gt;




&lt;h1&gt;
  
  
  Performance Actually Matters
&lt;/h1&gt;

&lt;p&gt;Bad extensions can slow down the browser.&lt;/p&gt;

&lt;p&gt;Especially when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;scripts run on every page,&lt;/li&gt;
&lt;li&gt;bundles are too large,&lt;/li&gt;
&lt;li&gt;or too many listeners exist.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I learned quickly that optimization matters even for small extensions.&lt;/p&gt;




&lt;h1&gt;
  
  
  Publishing Is Another Challenge
&lt;/h1&gt;

&lt;p&gt;After building your extension, you still need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;store listing,&lt;/li&gt;
&lt;li&gt;screenshots,&lt;/li&gt;
&lt;li&gt;icons,&lt;/li&gt;
&lt;li&gt;privacy policy,&lt;/li&gt;
&lt;li&gt;proper permissions explanation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Chrome Web Store reviews can reject extensions for small issues.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Chrome extension development is much more interesting than I expected.&lt;/p&gt;

&lt;p&gt;At first it feels confusing.&lt;/p&gt;

&lt;p&gt;But while building extensions, you learn:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;browser architecture,&lt;/li&gt;
&lt;li&gt;security,&lt;/li&gt;
&lt;li&gt;performance optimization,&lt;/li&gt;
&lt;li&gt;event-driven systems,&lt;/li&gt;
&lt;li&gt;and real product engineering.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re a beginner:&lt;br&gt;
don’t worry if things feel strange initially.&lt;/p&gt;

&lt;p&gt;Everyone gets confused by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;manifests,&lt;/li&gt;
&lt;li&gt;content scripts,&lt;/li&gt;
&lt;li&gt;and service workers at first.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Start with a small project,&lt;br&gt;
experiment a lot,&lt;br&gt;
and keep debugging.&lt;/p&gt;

&lt;p&gt;That’s honestly the best way to learn Chrome extensions 🚀&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>chrome</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Performance Optimization in Modern Web Applications</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Thu, 14 May 2026 07:32:23 +0000</pubDate>
      <link>https://forem.com/shubham_gupta_decf96a6ab2/performance-optimization-in-modern-web-applications-4f85</link>
      <guid>https://forem.com/shubham_gupta_decf96a6ab2/performance-optimization-in-modern-web-applications-4f85</guid>
      <description>&lt;p&gt;Performance optimization is no longer an optional improvement for web applications — it is a core requirement. Users expect applications to load instantly, respond smoothly, and work reliably across devices and network conditions. Even a one-second delay in load time can reduce conversions, engagement, and user satisfaction.&lt;/p&gt;

&lt;p&gt;In modern full-stack development, performance optimization spans frontend rendering, backend efficiency, database queries, network communication, caching, and deployment infrastructure. This blog explores practical strategies developers can use to build faster and more scalable web applications.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why Performance Matters
&lt;/h1&gt;

&lt;p&gt;Performance directly affects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User experience&lt;/li&gt;
&lt;li&gt;SEO rankings&lt;/li&gt;
&lt;li&gt;Conversion rates&lt;/li&gt;
&lt;li&gt;Retention and engagement&lt;/li&gt;
&lt;li&gt;Infrastructure cost&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A slow application increases bounce rates and frustrates users. Search engines also prioritize faster websites, making performance optimization critical for visibility.&lt;/p&gt;




&lt;h1&gt;
  
  
  Frontend Performance Optimization
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Reduce Bundle Size
&lt;/h2&gt;

&lt;p&gt;Large JavaScript bundles slow down page loads.&lt;/p&gt;

&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use tree shaking&lt;/li&gt;
&lt;li&gt;Remove unused dependencies&lt;/li&gt;
&lt;li&gt;Split code dynamically&lt;/li&gt;
&lt;li&gt;Compress assets using Brotli or Gzip&lt;/li&gt;
&lt;li&gt;Prefer lightweight libraries&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example (React Lazy Loading)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Suspense&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;Dashboard&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;./Dashboard&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;App&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;Suspense&lt;/span&gt; &lt;span class="nx"&gt;fallback&lt;/span&gt;&lt;span class="o"&gt;=&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;div&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="nx"&gt;Loading&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&amp;gt;}&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;Dashboard&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="sr"&gt;/Suspense&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 loads components only when required.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. Optimize Rendering
&lt;/h2&gt;

&lt;p&gt;Unnecessary re-renders can degrade UI responsiveness.&lt;/p&gt;

&lt;h3&gt;
  
  
  Techniques
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;React.memo&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Memoize callbacks with &lt;code&gt;useCallback&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Use &lt;code&gt;useMemo&lt;/code&gt; for expensive calculations&lt;/li&gt;
&lt;li&gt;Avoid deep component nesting&lt;/li&gt;
&lt;li&gt;Virtualize large lists&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ExpensiveComponent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;memo&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="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&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;data&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&amp;gt;&lt;/span&gt;&lt;span class="err"&gt;;
&lt;/span&gt;&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






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

&lt;p&gt;Images often account for the largest portion of page weight.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recommendations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Use WebP or AVIF formats&lt;/li&gt;
&lt;li&gt;Lazy-load offscreen images&lt;/li&gt;
&lt;li&gt;Serve responsive image sizes&lt;/li&gt;
&lt;li&gt;Use CDN image optimization&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"image.webp"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"optimized image"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Improve Core Web Vitals
&lt;/h2&gt;

&lt;p&gt;Google Core Web Vitals measure real user experience.&lt;/p&gt;

&lt;p&gt;Key metrics include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Largest Contentful Paint (LCP)&lt;/li&gt;
&lt;li&gt;First Input Delay (FID)&lt;/li&gt;
&lt;li&gt;Cumulative Layout Shift (CLS)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Optimization Tips
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Preload important assets&lt;/li&gt;
&lt;li&gt;Avoid layout shifts&lt;/li&gt;
&lt;li&gt;Minimize blocking JavaScript&lt;/li&gt;
&lt;li&gt;Use font optimization&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Backend Performance Optimization
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Database Query Optimization
&lt;/h2&gt;

&lt;p&gt;Poor database queries create major bottlenecks.&lt;/p&gt;

&lt;h3&gt;
  
  
  Best Practices
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Add proper indexes&lt;/li&gt;
&lt;li&gt;Avoid N+1 queries&lt;/li&gt;
&lt;li&gt;Use pagination&lt;/li&gt;
&lt;li&gt;Optimize joins&lt;/li&gt;
&lt;li&gt;Cache frequent queries&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example (MongoDB Index)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;db&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createIndex&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  2. Implement Caching
&lt;/h2&gt;

&lt;p&gt;Caching reduces server load and response times.&lt;/p&gt;

&lt;h3&gt;
  
  
  Types of Caching
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Browser caching&lt;/li&gt;
&lt;li&gt;CDN caching&lt;/li&gt;
&lt;li&gt;API caching&lt;/li&gt;
&lt;li&gt;Redis in-memory caching&lt;/li&gt;
&lt;li&gt;Database query caching&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example (Node.js + Redis)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cachedData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;redis&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;users&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&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;cachedData&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="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;cachedData&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;h2&gt;
  
  
  3. API Optimization
&lt;/h2&gt;

&lt;p&gt;Efficient APIs improve both frontend and backend performance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Recommendations
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Compress API responses&lt;/li&gt;
&lt;li&gt;Use pagination&lt;/li&gt;
&lt;li&gt;Return only required fields&lt;/li&gt;
&lt;li&gt;Implement rate limiting&lt;/li&gt;
&lt;li&gt;Use GraphQL selectively&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;GET&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt;&lt;span class="nx"&gt;users&lt;/span&gt;&lt;span class="p"&gt;?&lt;/span&gt;&lt;span class="nx"&gt;page&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nx"&gt;limit&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;20&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  4. Asynchronous Processing
&lt;/h2&gt;

&lt;p&gt;Heavy tasks should run in the background.&lt;/p&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Email sending&lt;/li&gt;
&lt;li&gt;Video processing&lt;/li&gt;
&lt;li&gt;Report generation&lt;/li&gt;
&lt;li&gt;Notification delivery&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Tools
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;BullMQ&lt;/li&gt;
&lt;li&gt;RabbitMQ&lt;/li&gt;
&lt;li&gt;Kafka&lt;/li&gt;
&lt;li&gt;AWS SQS&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Network Optimization
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Use a CDN
&lt;/h2&gt;

&lt;p&gt;A Content Delivery Network serves assets from servers closer to users.&lt;/p&gt;

&lt;p&gt;Benefits include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Faster load times&lt;/li&gt;
&lt;li&gt;Reduced latency&lt;/li&gt;
&lt;li&gt;Better scalability&lt;/li&gt;
&lt;li&gt;DDoS protection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Popular CDNs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cloudflare&lt;/li&gt;
&lt;li&gt;AWS CloudFront&lt;/li&gt;
&lt;li&gt;Akamai&lt;/li&gt;
&lt;li&gt;Fastly&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Enable Compression
&lt;/h2&gt;

&lt;p&gt;Compression significantly reduces response sizes.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example (Express.js)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;compression&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;compression&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&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;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;compression&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  3. Minimize HTTP Requests
&lt;/h2&gt;

&lt;p&gt;Reduce the number of requests by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combining assets&lt;/li&gt;
&lt;li&gt;Using SVG icons&lt;/li&gt;
&lt;li&gt;Removing unused scripts&lt;/li&gt;
&lt;li&gt;Lazy loading modules&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Performance Monitoring
&lt;/h1&gt;

&lt;p&gt;Optimization should be data-driven.&lt;/p&gt;

&lt;h2&gt;
  
  
  Important Monitoring Tools
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Lighthouse&lt;/li&gt;
&lt;li&gt;Chrome DevTools&lt;/li&gt;
&lt;li&gt;WebPageTest&lt;/li&gt;
&lt;li&gt;New Relic&lt;/li&gt;
&lt;li&gt;Datadog&lt;/li&gt;
&lt;li&gt;Grafana&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Metrics to Track
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Page load time&lt;/li&gt;
&lt;li&gt;API response time&lt;/li&gt;
&lt;li&gt;Memory usage&lt;/li&gt;
&lt;li&gt;CPU utilization&lt;/li&gt;
&lt;li&gt;Error rate&lt;/li&gt;
&lt;li&gt;Time to interactive&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Scalability and Infrastructure Optimization
&lt;/h1&gt;

&lt;h2&gt;
  
  
  1. Load Balancing
&lt;/h2&gt;

&lt;p&gt;Distribute traffic across multiple servers.&lt;/p&gt;

&lt;h3&gt;
  
  
  Popular Load Balancers
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;NGINX&lt;/li&gt;
&lt;li&gt;HAProxy&lt;/li&gt;
&lt;li&gt;AWS ALB&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  2. Horizontal Scaling
&lt;/h2&gt;

&lt;p&gt;Instead of increasing server size vertically, scale by adding more servers.&lt;/p&gt;

&lt;p&gt;Benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Better reliability&lt;/li&gt;
&lt;li&gt;Improved fault tolerance&lt;/li&gt;
&lt;li&gt;Higher availability&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3. Containerization
&lt;/h2&gt;

&lt;p&gt;Docker and Kubernetes help manage scalable applications efficiently.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Faster deployments&lt;/li&gt;
&lt;li&gt;Resource isolation&lt;/li&gt;
&lt;li&gt;Better scalability&lt;/li&gt;
&lt;li&gt;Consistent environments&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Common Performance Mistakes
&lt;/h1&gt;

&lt;p&gt;Avoid these frequent issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Over-fetching data&lt;/li&gt;
&lt;li&gt;Unoptimized database queries&lt;/li&gt;
&lt;li&gt;Large frontend bundles&lt;/li&gt;
&lt;li&gt;Memory leaks&lt;/li&gt;
&lt;li&gt;Blocking operations&lt;/li&gt;
&lt;li&gt;Excessive re-renders&lt;/li&gt;
&lt;li&gt;Lack of caching&lt;/li&gt;
&lt;li&gt;Ignoring monitoring&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Real-World Optimization Workflow
&lt;/h1&gt;

&lt;p&gt;A practical optimization process usually follows these steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Measure current performance&lt;/li&gt;
&lt;li&gt;Identify bottlenecks&lt;/li&gt;
&lt;li&gt;Prioritize high-impact fixes&lt;/li&gt;
&lt;li&gt;Implement optimizations&lt;/li&gt;
&lt;li&gt;Test under load&lt;/li&gt;
&lt;li&gt;Monitor continuously&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Performance optimization is iterative, not a one-time task.&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Modern web applications require performance-focused engineering at every layer of the stack. From frontend rendering and asset optimization to backend caching and infrastructure scaling, each improvement contributes to a smoother user experience.&lt;/p&gt;

&lt;p&gt;The best-performing applications are not necessarily the ones with the most features, but the ones that deliver fast, reliable, and efficient experiences consistently.&lt;/p&gt;

&lt;p&gt;By adopting performance optimization best practices early in development, teams can build scalable systems that remain responsive as traffic and complexity grow.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Performance is a competitive advantage. Users notice speed, responsiveness, and reliability immediately. Investing in optimization improves user satisfaction, SEO performance, and operational efficiency.&lt;/p&gt;

&lt;p&gt;A fast application is not just technically better — it is better for business.&lt;/p&gt;

</description>
      <category>performance</category>
      <category>frontendoptimization</category>
      <category>backendscalability</category>
      <category>fullstackdevelopment</category>
    </item>
    <item>
      <title>When a Simple Streaming Bug Turned Into a Deep Engineering Lesson</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Wed, 06 May 2026 18:52:35 +0000</pubDate>
      <link>https://forem.com/shubham_gupta_decf96a6ab2/when-a-simple-streaming-bug-turned-into-a-deep-engineering-lesson-22mi</link>
      <guid>https://forem.com/shubham_gupta_decf96a6ab2/when-a-simple-streaming-bug-turned-into-a-deep-engineering-lesson-22mi</guid>
      <description>&lt;p&gt;Recently, I worked on a streaming-related issue that initially looked very small.&lt;/p&gt;

&lt;p&gt;Users reported that some long-duration videos were buffering unexpectedly during playback.&lt;/p&gt;

&lt;p&gt;The pattern was interesting:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Videos started normally&lt;/li&gt;
&lt;li&gt;Playback worked fine initially&lt;/li&gt;
&lt;li&gt;After some time, buffering increased&lt;/li&gt;
&lt;li&gt;In certain cases, playback stopped completely&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At first, we assumed it could be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A frontend player issue&lt;/li&gt;
&lt;li&gt;Network instability&lt;/li&gt;
&lt;li&gt;Device-specific behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because for most users, buffering simply feels like “slow internet".&lt;/p&gt;

&lt;p&gt;But after deeper investigation, we realised the actual problem was much more complex.&lt;/p&gt;




&lt;h2&gt;
  
  
  Understanding the Real Issue
&lt;/h2&gt;

&lt;p&gt;After testing multiple scenarios, we noticed the issue mostly happened with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Long-duration videos&lt;/li&gt;
&lt;li&gt;Specific streaming versions&lt;/li&gt;
&lt;li&gt;Quality switches during playback&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Initially, video segments were loading correctly.&lt;/p&gt;

&lt;p&gt;However, during longer playback sessions:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Segment loading became inconsistent&lt;/li&gt;
&lt;li&gt;Buffer handling was delayed&lt;/li&gt;
&lt;li&gt;Retry requests increased&lt;/li&gt;
&lt;li&gt;Some quality-switch requests were not synchronizing properly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This created buffering loops that affected the viewing experience.&lt;/p&gt;

&lt;p&gt;The challenging part was that the issue was not consistently reproducible.&lt;/p&gt;

&lt;p&gt;Some videos worked perfectly.&lt;br&gt;
Some failed only after extended playback durations.&lt;/p&gt;

&lt;p&gt;That made debugging significantly harder.&lt;/p&gt;




&lt;h2&gt;
  
  
  How We Investigated
&lt;/h2&gt;

&lt;p&gt;To identify the root cause, we started validating the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple video durations&lt;/li&gt;
&lt;li&gt;Different encoded versions&lt;/li&gt;
&lt;li&gt;Various network conditions&lt;/li&gt;
&lt;li&gt;Adaptive bitrate switching&lt;/li&gt;
&lt;li&gt;Long playback sessions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We monitored:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Segment request timing&lt;/li&gt;
&lt;li&gt;Retry behavior&lt;/li&gt;
&lt;li&gt;Streaming responses&lt;/li&gt;
&lt;li&gt;Buffer health&lt;/li&gt;
&lt;li&gt;Playback synchronization&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After deeper analysis, we found that certain streaming versions were not handling segment transitions efficiently during long playback sessions.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Fix
&lt;/h2&gt;

&lt;p&gt;To improve playback stability, we optimised the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Streaming response handling&lt;/li&gt;
&lt;li&gt;Segment loading flow&lt;/li&gt;
&lt;li&gt;Retry handling logic&lt;/li&gt;
&lt;li&gt;Playback synchronization between streaming versions&lt;/li&gt;
&lt;li&gt;Buffer management behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We then validated the fixes using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Long-duration videos&lt;/li&gt;
&lt;li&gt;Multiple streaming qualities&lt;/li&gt;
&lt;li&gt;Different playback environments&lt;/li&gt;
&lt;li&gt;Extended playback testing sessions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The improvements were immediately visible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Playback became smoother&lt;/li&gt;
&lt;li&gt;Buffering reduced significantly&lt;/li&gt;
&lt;li&gt;Long-session streaming stabilized&lt;/li&gt;
&lt;li&gt;Overall streaming consistency improved&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  What This Experience Taught Me
&lt;/h2&gt;

&lt;p&gt;Before working closely with streaming systems, I thought video playback was mostly frontend-driven.&lt;/p&gt;

&lt;p&gt;Now I understand the real complexity exists in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Infrastructure&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;li&gt;Delivery optimization&lt;/li&gt;
&lt;li&gt;Media pipelines&lt;/li&gt;
&lt;li&gt;Buffer management&lt;/li&gt;
&lt;li&gt;Performance engineering&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Streaming platforms are one of the most fascinating examples of large-scale engineering.&lt;/p&gt;

&lt;p&gt;Users only see a simple “Play” button.&lt;/p&gt;

&lt;p&gt;Behind that button, thousands of engineering decisions work together in milliseconds to create a smooth viewing experience.&lt;/p&gt;

&lt;p&gt;Smooth playback is not magic.&lt;/p&gt;

&lt;p&gt;It’s engineering. ⚙️&lt;/p&gt;

&lt;h1&gt;
  
  
  Streaming #BackendEngineering #VideoStreaming #OTT #SoftwareEngineering #NodeJS #SystemDesign #PerformanceEngineering
&lt;/h1&gt;

</description>
      <category>streaming</category>
      <category>backendengineering</category>
      <category>performanceengineering</category>
      <category>videostreaming</category>
    </item>
    <item>
      <title>Designing a Universal Error Handler for Frontend &amp; Backend (React + Node.js)</title>
      <dc:creator>Shubham Gupta</dc:creator>
      <pubDate>Thu, 22 Jan 2026 18:27:28 +0000</pubDate>
      <link>https://forem.com/shubham_gupta_decf96a6ab2/designing-a-universal-error-handler-for-frontend-backend-react-nodejs-13d1</link>
      <guid>https://forem.com/shubham_gupta_decf96a6ab2/designing-a-universal-error-handler-for-frontend-backend-react-nodejs-13d1</guid>
      <description>&lt;p&gt;Error handling is one of those things we all do — but rarely design properly.&lt;/p&gt;

&lt;p&gt;In most projects, error handling grows organically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a few try/catch blocks&lt;/li&gt;
&lt;li&gt;some HTTP status checks&lt;/li&gt;
&lt;li&gt;random error messages sent from the backend&lt;/li&gt;
&lt;li&gt;UI logic guessing what went wrong
Eventually, the system becomes fragile.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article walks through how and why I designed a universal error-handling system that works across Backend (Node.js / Express / Next.js APIs) and Frontend (React / Next.js UI) — using a shared contract, not tight coupling.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Real Problem with Error Handling
&lt;/h2&gt;

&lt;p&gt;Most applications suffer from the same issues:&lt;/p&gt;

&lt;h2&gt;
  
  
  Backend problems
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Errors from DB, validation, or external APIs look different&lt;/li&gt;
&lt;li&gt;Internal stack traces leak to clients&lt;/li&gt;
&lt;li&gt;Error responses change over time&lt;/li&gt;
&lt;li&gt;Hard to debug production issues&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Frontend problems
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Every API returns a different error shape&lt;/li&gt;
&lt;li&gt;UI shows technical or confusing messages&lt;/li&gt;
&lt;li&gt;Error handling logic is duplicated everywhere&lt;/li&gt;
&lt;li&gt;Runtime crashes cause white screens
The core issue isn’t missing try/catch.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 The issue is lack of design.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Key Insight: Errors Are a Contract&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Instead of treating errors as exceptions, I started treating them as data.&lt;br&gt;
That led to one fundamental idea:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Frontend and backend should share an error contract, not implementations.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This single decision shaped the entire system.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Design Principle #1: Shared Contract, Not Tight Coupling&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The frontend and backend do not depend on each other’s code.&lt;br&gt;
They only agree on:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;error codes&lt;/li&gt;
&lt;li&gt;error structure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example error contract:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "success": false,
  "message": "User already exists",
  "code": "DUPLICATE_ERROR",
  "details": {
    "field": "email"
  },
  "traceId": "abc-123"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This gives us:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;consistency&lt;/li&gt;
&lt;li&gt;backward compatibility&lt;/li&gt;
&lt;li&gt;freedom to evolve each layer independently&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Design Principle #2: Backend Decides What Happened&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The backend is the source of truth.&lt;/p&gt;

&lt;p&gt;Its responsibility is to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;detect what went wrong&lt;/li&gt;
&lt;li&gt;categorize the error&lt;/li&gt;
&lt;li&gt;attach structured metadata&lt;/li&gt;
&lt;li&gt;assign a stable error code&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It does not decide how the error is shown.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internally, the backend normalizes:&lt;/li&gt;
&lt;li&gt;database errors&lt;/li&gt;
&lt;li&gt;validation failures&lt;/li&gt;
&lt;li&gt;authentication &amp;amp; authorization errors&lt;/li&gt;
&lt;li&gt;third-party API failures&lt;/li&gt;
&lt;li&gt;system-level crashes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything becomes a single, predictable error object.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Design Principle #3: Frontend Decides How to Show It&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The frontend owns user experience.&lt;/p&gt;

&lt;p&gt;It receives structured error data and decides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the message shown to users&lt;/li&gt;
&lt;li&gt;localization (i18n)&lt;/li&gt;
&lt;li&gt;UI presentation (toast, banner, modal)&lt;/li&gt;
&lt;li&gt;retry or recovery behavior&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This allows the same backend error to be shown differently in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;admin dashboards&lt;/li&gt;
&lt;li&gt;consumer apps&lt;/li&gt;
&lt;li&gt;mobile vs desktop UIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Technical message ≠ UI message — and that’s intentional.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Design Principle #4: Progressive Adoption&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This system is not all-or-nothing.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;use only backend utilities&lt;/li&gt;
&lt;li&gt;use only frontend hooks&lt;/li&gt;
&lt;li&gt;use both together for best results&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even if the backend doesn’t follow the contract perfectly, the frontend falls back safely.&lt;/p&gt;

&lt;p&gt;This makes the library practical for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;legacy systems&lt;/li&gt;
&lt;li&gt;gradual refactors&lt;/li&gt;
&lt;li&gt;monorepos with mixed stacks&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Design Principle #5: Hooks-Only, Modern React&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;All frontend APIs are built with hooks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;no class components&lt;/li&gt;
&lt;li&gt;no outdated patterns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;useAPIError()&lt;/code&gt; – handle API &amp;amp; network errors&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useAsyncData()&lt;/code&gt; – async operations with built-in error state&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useGlobalError()&lt;/code&gt; – app-wide error state&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;useNetworkStatus()&lt;/code&gt; – offline/online detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Runtime UI crashes are handled via a React error boundary, wrapped once at the app root.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Design Principle #6: TypeScript-First&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;TypeScript isn’t an add-on — it’s the foundation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;strict typing&lt;/li&gt;
&lt;li&gt;shared types between FE &amp;amp; BE&lt;/li&gt;
&lt;li&gt;discriminated unions for error types&lt;/li&gt;
&lt;li&gt;strong inference for consumers&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;fewer runtime surprises&lt;/li&gt;
&lt;li&gt;safer refactors&lt;/li&gt;
&lt;li&gt;better IDE experience&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Types are the documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;End-to-End Flow (How Everything Connects)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s the full journey of an error:&lt;/p&gt;

&lt;p&gt;Backend detects a failure&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Error is normalized into a standard structure&lt;/li&gt;
&lt;li&gt;API returns a predictable error response&lt;/li&gt;
&lt;li&gt;Frontend parses the error&lt;/li&gt;
&lt;li&gt;Error code is mapped to a user-friendly message&lt;/li&gt;
&lt;li&gt;UI displays a safe, meaningful response&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;At no point does the UI guess what went wrong.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Why This Matters in Production&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This approach gives you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;cleaner APIs&lt;/li&gt;
&lt;li&gt;better UX&lt;/li&gt;
&lt;li&gt;safer production behavior&lt;/li&gt;
&lt;li&gt;easier debugging (via trace IDs)&lt;/li&gt;
&lt;li&gt;a shared mental model for teams&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Error handling stops being “glue code” and becomes infrastructure.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Result: A Universal Error Handler&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I packaged this system as an open-source npm library:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @shubhamgupta-oss/universal-error-handler

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

&lt;/div&gt;



&lt;p&gt;It works with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;React&lt;/li&gt;
&lt;li&gt;Next.js&lt;/li&gt;
&lt;li&gt;Node.js&lt;/li&gt;
&lt;li&gt;Express&lt;/li&gt;
&lt;li&gt;TypeScript&lt;/li&gt;
&lt;li&gt;React 18 &amp;amp; 19&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;GitHub repo: &lt;a href="https://github.com/shubhamgupta-oss/universal-error-handler" rel="noopener noreferrer"&gt;https://github.com/shubhamgupta-oss/universal-error-handler&lt;/a&gt;&lt;br&gt;
NPM package: &lt;a href="https://www.npmjs.com/package/@shubhamgupta-oss/universal-error-handler" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/@shubhamgupta-oss/universal-error-handler&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Final Thoughts&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Good error handling isn’t about catching errors.&lt;/p&gt;

&lt;p&gt;It’s about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;defining responsibility&lt;/li&gt;
&lt;li&gt;designing contracts&lt;/li&gt;
&lt;li&gt;respecting separation of concerns&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you treat errors as a first-class system, everything else becomes simpler.&lt;/p&gt;

&lt;p&gt;If you’re building full-stack applications and struggling with inconsistent error handling, I hope this approach helps.&lt;/p&gt;

&lt;p&gt;Feedback, suggestions, and contributions are welcome. 🙌&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>javascript</category>
      <category>node</category>
      <category>react</category>
    </item>
  </channel>
</rss>
