<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Khushi_developer on Medium]]></title>
        <description><![CDATA[Stories by Khushi_developer on Medium]]></description>
        <link>https://medium.com/@khushi1399gupta?source=rss-441cba8b191f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ZuFAWiy1RI1TvXc6jqCniQ.png</url>
            <title>Stories by Khushi_developer on Medium</title>
            <link>https://medium.com/@khushi1399gupta?source=rss-441cba8b191f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 12:28:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@khushi1399gupta/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Rate Limiting for Beginners: Why It’s Needed and How It Works]]></title>
            <link>https://medium.com/codex/rate-limiting-for-beginners-why-its-needed-and-how-it-works-23549944b943?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/23549944b943</guid>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[rate-limiting]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Mon, 02 Feb 2026 04:41:01 GMT</pubDate>
            <atom:updated>2026-02-09T07:43:57.730Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Rate Limiting</strong></p><p>In simple terms, <strong>rate limiting means limiting the number of requests per second</strong> that a user or client can send to the server.</p><p>If a user crosses this limit, the server rejects the request.</p><p>The <strong>HTTP status code used for rate limiting is </strong><strong>429 – Too Many Requests</strong>.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F9TbgGqK1KhpnNORo9a%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbWlncjRpc3kzN2RyMzZmMG9rc3B1Z3A2MzAxemUzYmo5OG9yeDVndyZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F9TbgGqK1KhpnNORo9a%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZGo0MXB2ZWxkNjR3MHlndmQzbm8xdzF5eTRmajg4OHBwOW0xN3JuMSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F9TbgGqK1KhpnNORo9a%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="287" frameborder="0" scrolling="no"><a href="https://medium.com/media/7aa9c6a5342a7c9dd2f7f0f27ea2f723/href">https://medium.com/media/7aa9c6a5342a7c9dd2f7f0f27ea2f723/href</a></iframe><p><strong>Why We Use Rate Limiting</strong></p><p>We use <strong>rate limiting</strong> to save our server from abuse. Otherwise, any random hacker or bot can flood our system with requests, and actual users will not be able to use the application. This directly leads to <strong>business loss</strong>.</p><p>So rate limiting is put in place to <strong>protect our servers</strong>.</p><h3>Algorithms For Rate Limiting</h3><h3>Token Bucket</h3><p>In token bucket algorithm:</p><ul><li>We have a bucket with a fixed number of tokens, for example <strong>2 tokens</strong></li><li>Each request needs <strong>1 token</strong> to get processed</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Ftenor.com%2Fembed%2F16618159&amp;display_name=Tenor&amp;url=https%3A%2F%2Ftenor.com%2Fview%2Fbucket-dripping-drop-waves-bucket-of-water-gif-16618159&amp;image=https%3A%2F%2Fmedia.tenor.com%2F7CjWhWv8dYMAAAAN%2Fbucket-dripping.png&amp;type=text%2Fhtml&amp;schema=tenor" width="600" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/949ef8b4da9b6472cb701698469ee4fc/href">https://medium.com/media/949ef8b4da9b6472cb701698469ee4fc/href</a></iframe><p>So:</p><ul><li>First request comes → token is assigned → request is processed</li><li>Second request comes → token is assigned → request is processed</li></ul><h4><strong>Now the bucket is empty.</strong></h4><p>When the <strong>third request comes</strong>:</p><ul><li>There is <strong>no token available</strong></li><li>The request is <strong>rejected with 429 (Too Many Requests)</strong><br> or the client retries after some time</li></ul><pre>Tokens refill<br>            (fixed rate)<br>                 ↑<br>        +------------------+<br>        |   TOKEN BUCKET   |<br>        |   [ 2 Tokens ]  |<br>        +------------------+<br>              |   |<br>              |   |<br>        Req 1 |   | Req 2<br>              v   v<br>         +----------------+<br>         |  API SERVER    |<br>         +----------------+<br><br>Req 3 (no token available)<br>        |<br>        v<br>   ❌ Rejected (429)<br>   or client retries later</pre><blockquote>Important points:</blockquote><blockquote>Token bucket <strong>does not keep requests in a queue</strong></blockquote><blockquote>Tokens are added back to the bucket at a fixed rate</blockquote><blockquote>This algorithm <strong>allows burst traffic</strong></blockquote><pre>class TokenBucket {<br>  constructor(capacity, refillRatePerSecond) {<br>    this.capacity = capacity;           // max tokens<br>    this.tokens = capacity;              // current tokens<br>    this.refillRate = refillRatePerSecond;<br>    this.lastRefillTime = Date.now();<br>  }<br><br>  refill() {<br>    const now = Date.now();<br>    const elapsedSeconds = (now - this.lastRefillTime) / 1000;<br><br>    const tokensToAdd = elapsedSeconds * this.refillRate;<br>    this.tokens = Math.min(this.capacity, this.tokens + tokensToAdd);<br><br>    this.lastRefillTime = now;<br>  }<br><br>  allowRequest() {<br>    this.refill();<br><br>    if (this.tokens &gt;= 1) {<br>      this.tokens -= 1;<br>      return true; // request allowed<br>    }<br><br>    return false; // rate limited<br>  }<br>}</pre><h3>Leaky Bucket</h3><p>In leaky bucket algorithm:</p><ul><li>All incoming requests are put into a <strong>bucket (queue)</strong></li><li>Requests are processed at a <strong>fixed rate</strong>, for example <strong>2 requests at a time</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*auBPM3zhc2xw_ojr" /></figure><p>So:</p><ul><li>Even if many requests come together</li><li>Server will process only <strong>2 requests per second</strong></li><li>Remaining requests <strong>wait in the queue</strong></li></ul><p>If:</p><ul><li>The bucket becomes full</li><li>Extra requests are <strong>dropped</strong></li></ul><p>Important points:</p><ul><li>Leaky bucket <strong>does not allow burst traffic</strong></li><li>It provides a <strong>smooth and constant request flow</strong></li></ul><h3>Key Difference</h3><ul><li><strong>Token Bucket</strong> → allows burst, no queue</li><li><strong>Leaky Bucket</strong> → smooth output, uses queue</li></ul><blockquote>Why Rate Limiting Matters in Real Systems</blockquote><blockquote><strong>Quick Question: How does YouTube handle multiple video uploads while protecting its servers from abuse?</strong></blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Foy5TlJDzRD0e6FKlQ6%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExenB1bGxjaGRrN282Mnc2ajYxemt4MWNqYjFxaGVuMXBnc2pmOWpmdCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2Foy5TlJDzRD0e6FKlQ6%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExb2Y5MmVma3NnMGxvNXltNmtla3EyZWQ0a2MwZzN1dHQ4dHc2YWdkZiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Foy5TlJDzRD0e6FKlQ6%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="218" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ac2a93e692589ee310e9a97068dde7f/href">https://medium.com/media/6ac2a93e692589ee310e9a97068dde7f/href</a></iframe><p><strong><em>Answer</em></strong><em>:</em><strong><em> How YouTube Handles Multiple Uploads</em></strong></p><p><em>When many users upload videos at the same time:</em></p><p><em>User uploads a video from the web or mobile</em></p><p><em>Video is uploaded in </em><strong><em>chunks</em></strong><em> (small parts)</em></p><p><em>The request first goes to the </em><strong><em>load balancer</em></strong></p><p><em>The load balancer sends a request to the available </em><strong><em>upload server</em></strong></p><p><em>The upload server only </em><strong><em>accepts and stores</em></strong><em> the video</em></p><p><em>Heavy work, like video processing, happens </em><strong><em>later in the background</em></strong></p><p><em>This way, thousands of users can upload videos at the same time without blocking the system.</em></p><pre>User<br>  |<br>  v<br>[ Load Balancer ]<br>  |<br>  v<br>[ Upload Servers ]  ← stateless, scalable<br>  |<br>  v<br>[ Temporary Storage ]<br>  |<br>  v<br>[ Queue / Events ]<br>  |<br>  v<br>[ Video Processing Workers ]</pre><blockquote><strong>How YouTube Stays Safe from Server Abuse</strong></blockquote><p>If there is no protection, any hacker or bot can flood the system and real users will not be able to upload videos, which causes <strong>business loss</strong>.</p><p>So YouTube uses multiple layers of protection.</p><h3>1. Rate Limiting</h3><ul><li>Limits number of requests per second per user/IP</li><li>If limit is crossed → request rejected</li></ul><p>Status code used: <strong>429 (Too Many Requests)</strong></p><h3>2. Upload Quotas</h3><ul><li>Daily upload limit per account</li><li>New accounts get lower limits</li><li>Trusted users get higher limits</li></ul><h3>3. Authentication</h3><ul><li>Only logged-in users can upload</li><li>Each request is verified using tokens</li></ul><h3>4. Isolation</h3><ul><li>Upload servers only accept files</li><li>Processing happens separately</li><li>Even if uploads spike, core system stays safe</li></ul><h4><strong>Abuse Protection Diagram</strong></h4><pre>User Request<br>     |<br>     v<br>[ Rate Limiter ]<br>     |<br>     v<br>[ Auth Check ]<br>     |<br>     v<br>[ Quota Check ]<br>     |<br>     v<br>[ Load Balancer ]<br>     |<br>     v<br>Upload Server</pre><p>Keep learning.<br> Keep developing.<br> And don’t settle for shallow explanations.</p><p>Come back when you want to level up again 🙂</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23549944b943" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/rate-limiting-for-beginners-why-its-needed-and-how-it-works-23549944b943">Rate Limiting for Beginners: Why It’s Needed and How It Works</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ EPAM System Interview Questions (4 to 8 Years)]]></title>
            <link>https://medium.com/@khushi1399gupta/epam-system-interview-questions-4-to-8-years-9b271eb7935c?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b271eb7935c</guid>
            <category><![CDATA[interview-questions]]></category>
            <category><![CDATA[interview-preparation]]></category>
            <category><![CDATA[mern-stack]]></category>
            <category><![CDATA[job-interview]]></category>
            <category><![CDATA[interview]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 19:16:21 GMT</pubDate>
            <atom:updated>2025-11-03T19:16:21.019Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Tech Stack: MERN (MongoDB, Express, React, Node.js)<br>Hey everyone! A candidate recently shared their EPAM interview experience — compiling it here to help others prepare effectively! 🔥</em></p><blockquote><strong>📋 Overall Process:</strong><br> <strong>Technical Round 1</strong><br> <strong>Technical Round 2</strong><br> <strong>HR Round</strong></blockquote><p><strong>💻 Technical Round 1</strong><br>1. Explain the difference between var, let, and const and how scoping affects closures.<br>2. What are pure functions and how do they improve maintainability in React applications?<br>3. How does React Fiber enhance rendering performance?<br>4. What’s the difference between virtual DOM and real DOM?<br>5. How do you optimize React re-rendering — besides using React.memo()?<br>6. What are Higher-Order Components (HOCs) and how do they differ from hooks?<br>7. How would you manage global state across multiple components without Redux?<br>8. What are child processes in Node.js and how do you use them for heavy computations?<br>9. How do you manage rate limiting in Express to prevent abuse?<br>10. Explain the concept of circular dependencies in Node.js and how to resolve them.<br>11. Explain MongoDB indexing strategies and their trade-offs.<br>12. How do you handle large file uploads or streaming data in Node.js?</p><p><strong>💡 Scenario-Based Questions</strong><br>13. A React form is re-rendering on every keystroke — how do you optimize it?<br>14. A MongoDB query is taking too long — how do you debug and optimize it?<br>15. You discover memory leaks in your Node.js app. How do you identify and fix them?</p><p><strong>💻 Technical Round 2</strong><br>1. How would you structure a microservices architecture for a multi-tenant SaaS platform?<br>2. Explain how to implement API Gateway + Authentication + Rate Limiting in Express.<br>3. Discuss different caching layers (Redis, CDN, browser caching) and where to apply each.<br>4. How would you ensure observability in a distributed MERN app (logging, tracing, metrics)?<br>5. How can you use Docker and Kubernetes to scale your Node.js services?<br>6. What strategies do you use to secure APIs from XSS, CSRF, and injection attacks?<br>7. How do you implement role-based access control (RBAC) in your MERN stack app?</p><p><strong>💡Scenario-Based Questions (System Design Level)</strong><br>8. Your React app bundle has grown too large, causing slow load times. Describe how you’d analyze and reduce it.<br>9. You need to integrate a third-party API with strict rate limits — how would you design your system?<br>10. How would you implement real-time notifications efficiently for thousands of connected clients?<br>11. How do you ensure database consistency and rollback when multiple services are involved in a transaction?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b271eb7935c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything you need to know about GraphQL Authentication and Authorization]]></title>
            <link>https://medium.com/@khushi1399gupta/everything-you-need-to-know-about-graphql-authentication-and-authorization-ce9c1da77edd?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce9c1da77edd</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[sofware-engineering]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 15:44:58 GMT</pubDate>
            <atom:updated>2025-10-19T16:51:43.110Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/952/1*DeXiVedHQlAKqCs55pLgHg.png" /></figure><p>In this post, we are going to learn about both Authorization and Authentication in GraphQL.</p><p>Most developers coming from the REST API world would find this hard to comprehend, like how is it even possible. Authorization in GraphQL is different and can be done in many ways, but authentication is the same as we have in REST.</p><p>Let’s see them both in the below sections.</p><h3>Authentication</h3><p>Authentication is the process of verifying the identity of a user in a system. To verify the user’s identity, the user must supply a token or a key which the server will use to retrieve the user’s info from its databank. if the user’s info is in the databank then, the user is authenticated, that is, the user is allowed inside the system. If not, the server will tell the user that he is not authenticated and won’t be allowed access to the system.</p><p>Now, if a user is not authenticated, he has to request for registration via a registration form provided by the system. If the user’s token has expired, he has to request for a new token via the system’s login form.</p><p>There are ways in which we can authenticate users but the easiest and the most secured way is via <a href="https://jwt.io/">JWT (JSON Web Token</a>).</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FjZuKY2yJ2dj1OJfgoN%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExamY5bzJsNnRmemZra2NhZGdlb2FqcWpzbXBxYjl1Y3ptZ2VsaWN4MSZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FjZuKY2yJ2dj1OJfgoN%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExM251d3k3dGZucDNpd2lkMWJ5bnY1eWtmNGhhazRtZnNkOG9tenFvNSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FjZuKY2yJ2dj1OJfgoN%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/b99f871c5722ebfcb46b828cfe49a164/href">https://medium.com/media/b99f871c5722ebfcb46b828cfe49a164/href</a></iframe><p>JWT</p><blockquote>JWT is an open standard way in which information can be securely communicated between two entities. The information being transmitted is in a compact JSON object.</blockquote><p>JSON has three parts:</p><ul><li>Header: This contains the type of token used in signing the JWT and the signing algorithm being used, e.g HS256, etc.</li><li>Payload: This contains a statement about an entity. This statement is called a claim. There are different types of claims, registered, public or private claims.</li><li>Signature: This is generated by signing the encoded header, encoded payload, a secret, and the algorithm specified in the header.</li></ul><p>The final JWT output is three Base64-URL strings separated by dots.</p><pre>eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwczovL3NwYWNlYXBpLmNvbS9ncmFwaHFsIjp7InJvbGVzIjpbImFzdHJvbmF1dCJdLCJwZXJtaXNzaW9ucyI6WyJyZWFkOm93bl91c2VyIl19LCJpYXQiOjE1OTQyNTI2NjMsImV4cCI6MTU5NDMzOTA2Mywic3ViIjoiNjc4OTAifQ.Z1JPE53ca1JaxwDTlnofa3hwpS0PGdRLUMIrC7M3FCI</pre><p>You must be wondering what do we do with this string of random texts and numbers in the authentication. The data in the custom claim in the payload is generated for a particular when the user signs up in our system. The generated JWT is sent to the client.</p><p>The client stores this JWT in the browser, JWTs are mostly saved in the localStorage, though it depends on the choice of the developer. For each request to the server, this JWT is sent along with each request. There are many forms you can use to send the JWT, but most commonly it is appended in the Authorization header in a Bearer type authentication just like this:</p><pre>{<br><br>  &quot;headers&quot;: {<br><br>    &quot;Authorization&quot;: &quot;Bearer xxxxx.yyyyy.zzzz&quot;<br><br>  }<br><br>}</pre><p>The server will then retrieve the JWT token from the Authorization header, decode it to verify the user’s identity, to check that the user is already registered in the system.</p><p>Authenticating GraphQL is quite simple. We make use of queries and mutations. For a user to have access he has to register first, that’s why we have register pages on almost all websites. The registration hits a particular endpoint, for example, it is usually like this <a href="https://url_here/register">https://URL_HERE/register</a> API in a REST endpoint. For signing in, it usually in a URL like this: <a href="https://url_here/login">https://URL_HERE/login</a> in a REST endpoint.</p><p>🔒 Authorization in GraphQL</p><p>Once a user is <strong>authenticated</strong> (we know who they are), the next step is <strong>authorization</strong> — deciding <strong>what they are allowed to do</strong>.</p><blockquote><strong>Authentication:</strong> “Who are you?” ✅</blockquote><blockquote><strong>Authorization:</strong> “What can you access?” 🔑</blockquote><h4>🧩 How Authorization Works</h4><blockquote>Authorization usually involves a few common patterns:</blockquote><ol><li><strong>Role-Based Access Control (RBAC)</strong><br> Users have roles like admin, editor, or reader.<br> Each resolver checks the role before allowing access.<br> Example: Only admin can delete blog posts, but editor can create them.</li><li><strong>Field-Level Permissions</strong><br> Sometimes, only certain fields should be visible to certain users.<br> Example: salary or email fields might be hidden for normal users but visible to admin.</li><li><strong>Ownership Checks</strong><br> Some actions depend on whether the user owns the data.<br> Example: Users can edit their own blog posts but not others’ posts</li></ol><h3>⚡ Implementing Authorization Conceptually</h3><p>In GraphQL, you <strong>don’t need separate endpoints</strong> for different roles. Instead:</p><ol><li>Pass the <strong>user object from authentication</strong> (JWT decoded) into the context of Apollo Server.</li><li>In each resolver, <strong>check the user’s role or ownership</strong> before executing the action.</li><li>Return an <strong>error</strong> if the user isn’t authorized.</li></ol><p>So you flow becomes:</p><ol><li>Client sends JWT in the Authorization header.</li><li>Server decodes JWT → knows <strong>who the user is</strong>.</li><li>Resolver checks <strong>permissions</strong> → allows or denies the operation.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce9c1da77edd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering JavaScript Promises:You Can't-Miss ]]></title>
            <link>https://medium.com/@khushi1399gupta/mastering-javascript-promises-you-cant-miss-58a5fa347d1f?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/58a5fa347d1f</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[promises-in-javascript]]></category>
            <category><![CDATA[mastering]]></category>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[promises]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 07:50:24 GMT</pubDate>
            <atom:updated>2025-04-28T07:50:24.102Z</atom:updated>
            <content:encoded><![CDATA[<p><em>You Will be more confident on Promises!! ….after reading this Blog</em></p><blockquote>Promises are key to mastering async code in JavaScript. This blog will help you understand them quickly, boost your confidence, and make your code cleaner and more efficient!</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/0*X2e5X6CNYOTmTVJV.gif" /></figure><p>🔷 What is Promises?</p><p><em>A Promise is just an </em><strong><em>object</em></strong><em> that represents a </em><strong><em>future value</em></strong>.</p><p>It can be:</p><ul><li><strong>Pending</strong> (….waiting)</li><li><strong>Resolved</strong> (success)</li><li><strong>Rejected</strong> (failure)</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F6KT7O59RQl8QiqjEN2%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExeG91NWR1N3IxcDRqdHl3eGZ2dmFkMnplaDkxam04aHNiZGIzcjVsdyZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F6KT7O59RQl8QiqjEN2%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcXk1b3VtdjVwaXAwbmxoaWM3M2h6ZmtvNWNobWQ2bHJoZzZ5cHJuaCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F6KT7O59RQl8QiqjEN2%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/97244e39513220b50ad0974930fb6e48/href">https://medium.com/media/97244e39513220b50ad0974930fb6e48/href</a></iframe><pre><br>const promise = new Promise((resolve, reject) =&gt; {<br>  if (true) {<br>    resolve(&#39;Success&#39;);<br>  } else {<br>    reject(&#39;Error&#39;);<br>  }<br>});<br><br>promise.then(result =&gt; console.log(result)); // &quot;Success&quot;<br>promise.catch(error =&gt; console.log(error));  // if error</pre><p>🔷 What is <strong>async/await</strong>?</p><ul><li>async/await is <strong>just a prettier way</strong> to <strong>write promises</strong>.</li><li>Instead of using .then(), you can <strong>pause</strong> code execution with await.</li></ul><p>Example:</p><pre>async function getData() {<br>  try {<br>    const result = await promise;   // waits until promise resolves<br>    console.log(result);<br>  } catch (error) {<br>    console.log(error);<br>  }<br>}</pre><p><em>✅ </em><em>await </em><strong><em>waits</em></strong><em> for the promise to resolve and then continues.<br> ✅ </em><em>try-catch handles errors when using </em><em>await.</em></p><p>🔥 KEY POINTs:</p><ul><li>await only works <strong>inside an async function</strong>.</li><li>await <strong>does NOT block</strong> the whole program — it just <strong>pauses</strong> the current function until the Promise resolves.</li><li>Promises and async/await are both based on <strong>microtasks queue</strong> (executed after current synchronous code).</li></ul><h4>🚀 So quickly answer the Bonus Q:</h4><p>What will be the output of the following ?…..</p><pre>console.log(&#39;1&#39;);<br><br>setTimeout(() =&gt; {<br>  console.log(&#39;2&#39;);<br>}, 0);<br><br>Promise.resolve().then(() =&gt; {<br>  console.log(&#39;3&#39;);<br>});<br><br>console.log(&#39;4&#39;);</pre><p>Correct Output:</p><pre>1<br>4<br>3<br>2</pre><p>Explaination…….</p><p><strong><em>Synchronous</em></strong><em> code runs </em><strong><em>first</em></strong><em>.<br> Then, the </em><strong><em>microtask queue</em></strong><em> (Promises) runs </em><strong><em>before</em></strong><em> the </em><strong><em>macrotask queue</em></strong><em> (setTimeout). 🕹️</em></p><blockquote>Let’s dive deep into <strong>Promises</strong> and explore everything you need to know…</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F0obkY4DmrH4Vw4ziYz%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExYm91YWUxOXh4b2dpb25obmp4YjlqdnZhdzF4MHp5N3JxMW8zcGZtZCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2F0obkY4DmrH4Vw4ziYz%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZnZ5cGhrbnIzOGVyY2l1Ym8waDJhZGZxaWgweDkyNm9qZzRueHp1dCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F0obkY4DmrH4Vw4ziYz%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/98d66dfafc6f663077482f7f652989a7/href">https://medium.com/media/98d66dfafc6f663077482f7f652989a7/href</a></iframe><h4>Promise Chaining: ⛓️</h4><p>Promises allow you to chain multiple .then() calls together. This is incredibly useful when you have a series of asynchronous tasks that need to run one after another.</p><pre>new Promise((resolve, reject) =&gt; {<br>  resolve(5);<br>})<br>  .then((result) =&gt; {<br>    console.log(result);  // 5<br>    return result * 2;    // Returns a new value to be passed to the next .then()<br>  })<br>  .then((result) =&gt; {<br>    console.log(result);  // 10<br>    return result + 3;<br>  })<br>  .then((result) =&gt; {<br>    console.log(result);  // 13<br>  })<br>  .catch((error) =&gt; {<br>    console.log(error);<br>  });</pre><h3>Promise Methods</h3><ol><li>Promise.all()</li></ol><p>Promise.all() is used to <strong>wait for multiple promises to resolve</strong>. It takes an array of promises and returns a single promise that resolves when all the promises are fulfilled.</p><pre>let promise1 = Promise.resolve(3);<br>let promise2 = new Promise((resolve, reject) =&gt; setTimeout(resolve, 100, &#39;foo&#39;));<br>let promise3 = 42;<br><br>Promise.all([promise1, promise2, promise3])<br>  .then((values) =&gt; {<br>    console.log(values); // [3, &quot;foo&quot;, 42]<br>  })<br>  .catch((error) =&gt; {<br>    console.log(error); // If any promise fails, this will be called<br>  });</pre><blockquote><strong>If any promise rejects, the entire </strong><strong>Promise.all() rejects with that error.</strong></blockquote><p>2. Promise.race()</p><p>Promise.race() takes an array of promises and <strong>returns a promise</strong> that resolves or rejects as soon as <strong>one of the promises</strong> resolves or rejects.</p><pre>let promise1 = new Promise((resolve, reject) =&gt; setTimeout(resolve, 500, &#39;first&#39;));<br>let promise2 = new Promise((resolve, reject) =&gt; setTimeout(resolve, 100, &#39;second&#39;));<br><br>Promise.race([promise1, promise2])<br>  .then((value) =&gt; {<br>    console.log(value); // &#39;second&#39; (the fastest promise)<br>  })<br>  .catch((error) =&gt; {<br>    console.log(error);<br>  });</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F0YD2XkGOxUasyvBk1C%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F0YD2XkGOxUasyvBk1C%2Fgiphy.gif%3Fcid%3Decf05e47mabb9ya1ybyfn1j7yxrmnmt3ayf6ek8qwcctw3az%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia3.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExc2VxN3B4eHhjNnAyZmRndWVkMTQxczhucHZlMDN6ZGE2NHV1d3M5ZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F0YD2XkGOxUasyvBk1C%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fdf0365a32487b4b2ba227917068658/href">https://medium.com/media/2fdf0365a32487b4b2ba227917068658/href</a></iframe><blockquote>It resolves or rejects <strong>as soon as the first promise resolves or rejects</strong>, regardless of the others.</blockquote><p>3. Promise.allSettled()</p><p>Promise.allSettled() returns a promise that resolves after <strong>all of the input promises have settled</strong>, whether they are fulfilled or rejected.</p><pre>let promise1 = Promise.resolve(42);<br>let promise2 = new Promise((resolve, reject) =&gt; reject(&#39;Error&#39;));<br>let promise3 = new Promise((resolve, reject) =&gt; resolve(&#39;Success&#39;));<br><br>Promise.allSettled([promise1, promise2, promise3]).then((results) =&gt; {<br>  console.log(results);<br>  // [<br>  //   { status: &quot;fulfilled&quot;, value: 42 },<br>  //   { status: &quot;rejected&quot;, reason: &quot;Error&quot; },<br>  //   { status: &quot;fulfilled&quot;, value: &quot;Success&quot; }<br>  // ]<br>});</pre><blockquote>Useful when you want to know the <strong>final state</strong> of each promise (whether fulfilled or rejected), but you don’t care if one fails.</blockquote><p>4. Promise.any()</p><p>Promise.any() returns a promise that <strong>resolves as soon as one of the input promises resolves</strong>, or rejects if all promises are rejected.</p><pre>let promise1 = Promise.reject(&#39;Error 1&#39;);<br>let promise2 = Promise.reject(&#39;Error 2&#39;);<br>let promise3 = Promise.resolve(&#39;Success&#39;);<br><br>Promise.any([promise1, promise2, promise3])<br>  .then((value) =&gt; {<br>    console.log(value); // &#39;Success&#39;<br>  })<br>  .catch((error) =&gt; {<br>    console.log(error); // Only triggered if all promises reject<br>  });</pre><blockquote>If all promises <strong>reject</strong>, it will return a <strong>AggregateError</strong>.</blockquote><h3>Conclusion:</h3><p>Promises are essential for working with asynchronous code in JavaScript. With <strong>Promise chaining</strong> and the various <strong>Promise methods</strong>, you can handle complex async workflows efficiently.</p><ul><li><strong>async/await</strong> is just syntactic sugar over promises, but promises themselves are powerful tools for managing async operations.</li><li><strong>Promise.all(), Promise.race(), Promise.allSettled(),</strong> and <strong>Promise.any()</strong> offer flexibility in handling multiple async tasks.</li></ul><blockquote>Now that you’ve got a solid understanding of async/await and Promises, let’s go for something <strong>even more challenging</strong>! 🔥</blockquote><p>Consider the following code….</p><pre>console.log(&#39;start&#39;);<br><br>async function task1() {<br>  console.log(&#39;task1 start&#39;);<br>  await task2();<br>  console.log(&#39;task1 end&#39;);<br>}<br><br>async function task2() {<br>  console.log(&#39;task2 start&#39;);<br>  await task3();<br>  console.log(&#39;task2 end&#39;);<br>}<br><br>async function task3() {<br>  console.log(&#39;task3 start&#39;);<br>  await new Promise(resolve =&gt; setTimeout(resolve, 1000));<br>  console.log(&#39;task3 end&#39;);<br>}<br><br>task1();<br><br>console.log(&#39;end&#39;);</pre><p>Comment your answer……</p><p>Happy coding :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58a5fa347d1f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Apache Kafka Explained: Learn How Kafka Works]]></title>
            <link>https://medium.com/@khushi1399gupta/apache-kafka-explained-learn-how-kafka-works-d7661aa971e7?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7661aa971e7</guid>
            <category><![CDATA[kafka-producer]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[kafka-connect]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Fri, 28 Mar 2025 21:58:42 GMT</pubDate>
            <atom:updated>2025-03-28T21:58:42.941Z</atom:updated>
            <content:encoded><![CDATA[<h4>Introduction: The Data Revolution</h4><p>In today’s fast-paced digital world, applications generate massive amounts of data every second. From <em>user clicks</em> and <em>sensor readings</em> to <em>financial transactions</em> and <em>social media interactions</em>, managing this continuous stream of information is crucial. This is where Apache Kafka comes into play.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*lV8Ceygb3CF2zX-XLi2_Eg.png" /></figure><h4>What is Kafka, Really?</h4><p>Apache Kafka is not just another technology — it’s a distributed streaming platform that has revolutionized how modern applications handle real-time data. Think of Kafka as a high-speed, fault-tolerant messaging system that can handle millions of messages per second.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl3vRd3vZPrApPqzjq%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl3vRd3vZPrApPqzjq%2Fgiphy.gif%3Fcid%3D790b76112ah09ldahb3tdq40j3asl8zrbl13uqd6agvcho6s%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbnV1aXBiaHEzdm1wcGd2N3doY2V6ZXpnZGE4aDlhNXp4c2lveWJsdyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Fl3vRd3vZPrApPqzjq%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="307" frameborder="0" scrolling="no"><a href="https://medium.com/media/c3126f698a2c6628786114ee91e5b50e/href">https://medium.com/media/c3126f698a2c6628786114ee91e5b50e/href</a></iframe><p>Lets see some key characters tics of kafka</p><h4>Key Characteristics</h4><ul><li><strong>Distributed</strong>: Works across multiple servers</li><li><strong>Scalable</strong>: Can handle tremendous amounts of data</li><li><strong>Fault-Tolerant</strong>: Continues working even if some components fail</li><li><strong>Real-Time</strong>: Processes data almost instantly</li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3ohhwJlKHGchQUtvBS%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3ohhwJlKHGchQUtvBS%2Fgiphy.gif%3Fcid%3D790b76113soc1sobps50fur1fmud5pf59dznhm33f8jdgwk8%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia4.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExNXJ1MWxtY29sZndpd2RveGN1OTVuZWJsdWNsbTRkMjBpcXp1ZjdneCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3ohhwJlKHGchQUtvBS%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e118ce7491ba20b0c0e9dfc7327af18/href">https://medium.com/media/2e118ce7491ba20b0c0e9dfc7327af18/href</a></iframe><h3>Core Concepts: Breaking Down Kafka’s Architecture</h3><h4>1. Topics</h4><p>A topic in Kafka is like a category or feed name to which records are published. Imagine it as a pipeline where data flows…</p><p><strong><em>Example Topics:</em></strong><em><br>- user_logins<br>- product_purchases<br>- sensor_readings</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*692fc6cTXJm0yuymxauB2w.png" /></figure><h4><strong>2. Producers and Consumers</strong></h4><ul><li><strong>Producers</strong>: Applications that send (publish) data to Kafka topics</li><li><strong>Consumers</strong>: Applications that read (subscribe) data from topics</li></ul><figure><img alt="Representation of kafka flow" src="https://cdn-images-1.medium.com/max/771/1*yPPAGaQUFKlZaztOo2BHkg.png" /></figure><h4>3. Brokers and Clusters</h4><ul><li>A <strong>broker</strong> is a single Kafka server</li><li>A <strong>cluster</strong> is a group of brokers working together</li><li>Provides high availability and load balancing</li></ul><h3><strong>Now let see some Real-World Use Cases</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9Dg2PnhD3ieAa3QF_hrp1A.png" /></figure><h3>1. Microservices Communication</h3><p>Kafka enables different services to communicate without direct coupling:</p><ul><li>User registration service publishes to a topic</li><li>Analytics service consumes from the same topic</li><li>Notification service also consumes the topic</li></ul><h3>2. Event Tracking</h3><ul><li>E-commerce platforms track user interactions</li><li>Social media platforms monitor real-time engagement</li><li>IoT devices send continuous sensor data</li></ul><h3>3. Log Aggregation</h3><p>Collect logs from multiple services and centralize them for analysis</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FMpLphYAo2vO4P2Facx%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExMnJrbjVzZXZ4cWN3MG52OWRoYnJnZXE4YTh1cWp5ZnVjOTQ3d294MyZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FMpLphYAo2vO4P2Facx%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExc29wc2pxM2Z3anlocms5N3p1amJ5bHA0aW82Z29oMjU5dmprZmtsaiZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FMpLphYAo2vO4P2Facx%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ad34b22a63d4365ff6195a169666b94/href">https://medium.com/media/6ad34b22a63d4365ff6195a169666b94/href</a></iframe><h3>Getting Started: Basic Kafka Setup</h3><h3>Step-by-Step Installation (Basic)</h3><ol><li>Install Java (Kafka requires Java)</li><li>Download Kafka from Apache’s website</li><li>Start Zookeeper (Kafka’s coordination service)</li><li>Start Kafka server</li></ol><h3>Simple Python Example</h3><pre>from kafka import KafkaProducer, KafkaConsumer<br><br># Producing a message<br>producer = KafkaProducer(bootstrap_servers=[&#39;localhost:9092&#39;])<br>producer.send(&#39;user_actions&#39;, b&#39;New user registered&#39;)<br><br># Consuming messages<br>consumer = KafkaConsumer(&#39;user_actions&#39;)<br>for message in consumer:<br>    print(message.value)</pre><h3>Advantages of Kafka</h3><h3>🚀 Performance</h3><ul><li>Can handle millions of messages/second</li><li>Low latency (milliseconds)</li></ul><h3>🔒 Reliability</h3><ul><li>Replicates data across multiple brokers</li><li>Supports message replay and fault tolerance</li></ul><blockquote>Conclusion: The Future of Data Streaming</blockquote><blockquote>Kafka isn’t just a technology — it’s a paradigm shift in how we think about data movement. As applications become more distributed and real-time, Kafka provides the backbone for modern, scalable architectures.</blockquote><p>Happy coding…………………:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7661aa971e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering Node.js Basics]]></title>
            <link>https://medium.com/@khushi1399gupta/mastering-node-js-basics-4ca0543ef8df?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ca0543ef8df</guid>
            <category><![CDATA[node-js-development]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[node-js-tutorial]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[node]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Sat, 28 Dec 2024 21:19:52 GMT</pubDate>
            <atom:updated>2024-12-28T21:25:13.032Z</atom:updated>
            <content:encoded><![CDATA[<p>So actually what is Node.js?</p><p>Node.js is an <strong>open-source runtime environment</strong> that allows developers to run JavaScript code outside a web browser. Built on the <strong>V8 JavaScript engine</strong> (used by Google Chrome), Node.js is known for its speed and efficiency. It is particularly well-suited for building scalable, real-time, and data-intensive applications.</p><blockquote>If you’re looking to handle millions of connections seamlessly or create apps that thrive under heavy data loads, Node.js is your best bet.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*JlFXsQ4FyLBtTEiu" /><figcaption>Photo by <a href="https://unsplash.com/@yortrosal?utm_source=medium&amp;utm_medium=referral">Jorge Rosal</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Key Features of Node.js</h3><ol><li><strong>Non-blocking I/O</strong><br>Node.js uses an <strong>event-driven, non-blocking I/O model</strong>, allowing operations like file reading, HTTP requests, or database queries to run asynchronously without blocking the main thread. This enables high concurrency.</li><li><strong>Single-threaded Event Loop</strong><br>Node.js operates on a single thread using an <strong>event loop</strong> for handling multiple requests efficiently, without creating multiple threads.</li><li><strong>Cross-platform</strong><br>Node.js runs on various platforms, including Windows, macOS, and Linux.</li><li><strong>NPM (Node Package Manager)</strong><br>Node.js comes with NPM, the world’s largest package manager, offering reusable libraries and tools.</li><li><strong>Scalability</strong><br>Node.js is ideal for handling many simultaneous connections, such as in chat applications or streaming services.</li><li><strong>Fast and Efficient</strong><br>With the V8 engine, Node.js compiles JavaScript to machine code, resulting in fast execution.</li></ol><h3>What is process in Node.js?</h3><p>The process object in Node.js is a global object that provides information about and control over the current Node.js process. It allows access to environment variables, event lifecycle, and command-line arguments.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fk1aqHacjJxN1xmFtyR%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExeGhsZ2h4d2RnY2J2bm9wMGdkOG84NHc3eWZhcG9saXh4eGlpcWZ6eSZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2Fk1aqHacjJxN1xmFtyR%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdDAyNHhrYTNjaHRtaHE2NGF2dG9kbjVqOG5rdXdndGFtbjJqcmI2eCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2Fk1aqHacjJxN1xmFtyR%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/6115de27c40563fd8c2e59d02514e2a4/href">https://medium.com/media/6115de27c40563fd8c2e59d02514e2a4/href</a></iframe><pre>// Access environment variables<br>console.log(&#39;Environment Variable SECRET:&#39;, process.env.SECRET || &#39;Not Defined&#39;);<br><br>// Command-line arguments<br>const args = process.argv.slice(2);<br>console.log(&#39;Command-line Arguments:&#39;, args);<br><br>// Listening to process events<br>process.on(&#39;exit&#39;, (code) =&gt; {<br>  console.log(`Process exited with code: ${code}`);<br>});<br><br>// Handle termination signal<br>process.on(&#39;SIGINT&#39;, () =&gt; {<br>  console.log(&#39;Process interrupted. Exiting...&#39;);<br>  process.exit();<br>});</pre><h3>What are Streams in Node.js?</h3><p>Streams are a core concept in Node.js, used to handle <strong>reading</strong> and <strong>writing</strong> data piece by piece (in small chunks). They improve performance, especially for large files or datasets.</p><p><strong>Types of Streams:</strong></p><ol><li><strong>Readable Streams</strong>: For reading data.</li><li><strong>Writable Streams</strong>: For writing data.</li><li><strong>Duplex Streams</strong>: For reading and writing data.</li><li><strong>Transform Streams</strong>: For modifying or transforming data during read/write operations</li></ol><pre>const fs = require(&#39;fs&#39;);<br><br>// Read from one file and write to another using piping<br>const readableStream = fs.createReadStream(&#39;input.txt&#39;);<br>const writableStream = fs.createWriteStream(&#39;output.txt&#39;);<br><br>readableStream.pipe(writableStream);<br><br>console.log(&#39;Data piped successfully.&#39;);</pre><h3>What is Buffer in Node.js?</h3><p>A <strong>Buffer</strong> in Node.js is a temporary memory storage area for binary data. It is used to handle binary streams of data, such as files, video streams, or network packets.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FTLnWsIBRegQyWxG4Dw%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExcWpiaGd3Z3RsZDJxeDc4MnZxcDd3ZzI3ZGdoNjRtMmQ4ajhpYm9pMSZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FTLnWsIBRegQyWxG4Dw%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExbTBiMGIxMDZkZDRxZmZ6YXh2eWNzMzN3NW83OGlhNnYxa3d3OTYwdSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FTLnWsIBRegQyWxG4Dw%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/b180ba14cf4a127ed45869ef0d2d6bf3/href">https://medium.com/media/b180ba14cf4a127ed45869ef0d2d6bf3/href</a></iframe><pre>const buffer = Buffer.from(&#39;Hello, Node.js!&#39;);<br>console.log(buffer); // Prints: &lt;Buffer 48 65 6c 6c 6f 2c 20 4e 6f 64 65 2e 6a 73 21&gt;<br>console.log(buffer.toString()); // Prints: Hello, Node.js!</pre><h3>What is Middleware?</h3><p>Middleware refers to functions executed between receiving a request and sending a response. Middleware in Node.js (often used with frameworks like Express.js) can perform tasks like logging, authentication, or request parsing.</p><pre>const express = require(&#39;express&#39;);<br>const app = express();<br><br>// Middleware to log request details<br>app.use((req, res, next) =&gt; {<br>  console.log(`${req.method} ${req.url}`);<br>  next(); // Pass control to the next middleware<br>});<br><br>app.get(&#39;/&#39;, (req, res) =&gt; {<br>  res.send(&#39;Hello, Middleware!&#39;);<br>});<br><br>app.listen(3000, () =&gt; console.log(&#39;Server running on port 3000&#39;));</pre><h3>What is Encoding and Why Use It?</h3><p>Encoding converts data from one format to another, often for transmission or storage. For example, UTF-8 is a common text encoding format. In Node.js, encoding is commonly used when working with strings and files.</p><pre>const fs = require(&#39;fs&#39;);<br><br>fs.writeFile(&#39;example.txt&#39;, &#39;Hello, Node.js!&#39;, &#39;utf8&#39;, (err) =&gt; {<br>  if (err) throw err;<br>  console.log(&#39;File written with UTF-8 encoding.&#39;);<br>});</pre><h3>What is the Event Loop?</h3><p>The Event Loop is the mechanism that allows Node.js to perform non-blocking I/O operations by offloading tasks to the system kernel. It continuously checks for events, executes callbacks, and processes pending tasks.</p><h3>What is Chaining in Node.js?</h3><p>Chaining connects the output of one stream to another, forming a sequence of stream operations. It is commonly used with pipes for tasks like reading, transforming, and writing data.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FDoWqmz4TGL3Tk9jwTZ%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExYnRmMm82MGgzYWM2d2h5Zmk4bjN2eTZ1N3k4YjRuaGVwMm90ZnJ1byZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FDoWqmz4TGL3Tk9jwTZ%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExZTh6amYxazRtdWZsZDlpM29vaGM4NDkxeGk1NWRjMGlycWhzdmR4bSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FDoWqmz4TGL3Tk9jwTZ%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/43aa174e3b3a2985e9b88c34a23e2fa5/href">https://medium.com/media/43aa174e3b3a2985e9b88c34a23e2fa5/href</a></iframe><pre>const fs = require(&#39;fs&#39;);<br>const zlib = require(&#39;zlib&#39;);<br><br>// Compress a file using chaining<br>fs.createReadStream(&#39;input.txt&#39;)<br>  .pipe(zlib.createGzip())<br>  .pipe(fs.createWriteStream(&#39;input.txt.gz&#39;));<br><br>console.log(&#39;File compressed successfully.&#39;);</pre><h3>When Not to Use Node.js?</h3><p>Node.js is not ideal for:</p><ul><li><strong>CPU-intensive tasks</strong>: Its single-threaded nature makes it unsuitable for heavy computation.</li><li><strong>Blocking operations</strong>: Tasks requiring synchronous/blocking behavior can degrade performance.</li></ul><h3>How to Debug Node.js Applications?</h3><p>Node.js provides several debugging options:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FVcdbi5o470i9FACaZO%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExN2xyYmp2M2Z1Mnh5dXQwY2NzMnZjNTlhZmFrOTJwZ2xkMHRvbjQxOCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FVcdbi5o470i9FACaZO%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdTFuc2N6b3JrM2Z5aXA3OTg0OWZkaTk3MmQ1N3dvN3BhN3ZzcWJhZSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FVcdbi5o470i9FACaZO%2Fgiphy_s.gif&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/938bd81c200711fed152f30ce62ed2ac/href">https://medium.com/media/938bd81c200711fed152f30ce62ed2ac/href</a></iframe><ol><li>Built-in Debugger</li></ol><pre>node --inspect server.js</pre><ol><li><strong>Popular Tools</strong>:</li></ol><ul><li>Visual Studio Code Debugger</li><li>Node Inspector</li><li>Debugging libraries (e.g., debug).</li></ul><p><strong>Code Example: Debugging with </strong><strong>inspect</strong></p><pre>node --inspect-brk app.js</pre><h3>What is Piping in Node.js?</h3><p>Piping is a mechanism for connecting the output of one stream to the input of another, allowing data to flow seamlessly.</p><pre>const fs = require(&#39;fs&#39;);<br><br>// Copy content from one file to another<br>const readable = fs.createReadStream(&#39;source.txt&#39;);<br>const writable = fs.createWriteStream(&#39;destination.txt&#39;);<br><br>readable.pipe(writable);<br><br>console.log(&#39;File copied using piping.&#39;);</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ca0543ef8df" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frontend System Design | Performance & Optimization Techniques ]]></title>
            <link>https://medium.com/@khushi1399gupta/frontend-system-design-performance-optimization-techniques-1689f6970481?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/1689f6970481</guid>
            <category><![CDATA[optimization-techniques]]></category>
            <category><![CDATA[front-end-developer]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[frontend-developer]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Sat, 09 Nov 2024 18:43:14 GMT</pubDate>
            <atom:updated>2024-11-09T18:43:14.015Z</atom:updated>
            <content:encoded><![CDATA[<h3>1) Code splitting in React JS</h3><p>Code splitting in React optimizes loading times by splitting large bundles into smaller, demand-loaded chunks. This technique delays loading non-critical code until it’s needed, which improves the initial load time, interaction speed, and reduces abandonment rates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*V-1Xz8h0NMsXe9Ck" /><figcaption>Photo by <a href="https://unsplash.com/@ilyapavlov?utm_source=medium&amp;utm_medium=referral">Ilya Pavlov</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Setup with Code Splitting</h3><ol><li><strong>Create Project</strong>: npm create vite@latest with React and TypeScript.</li><li><strong>Install Dependencies</strong>: npm install react-router-dom.</li><li><strong>Create Pages</strong>: Create a src/pages folder with files (e.g., Profile.tsx, About.tsx) that export simple components.</li></ol><h3>Basic Routing without Code Splitting</h3><p>Traditionally, React apps load all routes upfront:</p><pre>&lt;Route path=&#39;about&#39; element={&lt;About /&gt;} /&gt;</pre><h3>Applying Code Splitting</h3><p>Use React.lazy to load routes on demand:</p><pre>const About = lazy(() =&gt; import(&#39;./pages/About&#39;));<br>&lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>  &lt;Route path=&#39;about&#39; element={&lt;About /&gt;} /&gt;<br>&lt;/Suspense&gt;<br></pre><h4>Route-Based Code Splitting</h4><ul><li><strong>Dynamic Route-Based Imports</strong> load only the resources needed for the current route, reducing the initial bundle size and deferring other page resources until navigation.</li><li>Using React.lazy and Suspense in combination with react-router, we can dynamically load route-based components.</li></ul><pre>import React, { lazy, Suspense } from &quot;react&quot;;<br>import { Switch, Route, BrowserRouter as Router } from &quot;react-router-dom&quot;;<br><br>const Home = lazy(() =&gt; import(&quot;./Home&quot;));<br>const About = lazy(() =&gt; import(&quot;./About&quot;));<br>const Contact = lazy(() =&gt; import(&quot;./Contact&quot;));<br><br>function App() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>        &lt;Switch&gt;<br>          &lt;Route exact path=&quot;/&quot; component={Home} /&gt;<br>          &lt;Route path=&quot;/about&quot; component={About} /&gt;<br>          &lt;Route path=&quot;/contact&quot; component={Contact} /&gt;<br>        &lt;/Switch&gt;<br>      &lt;/Suspense&gt;<br>    &lt;/Router&gt;<br>  );<br>}<br><br>export default App;</pre><h3>Private/Public Routes</h3><p>Define PrivateRoutes and PublicRoutes components. Toggle them based on authentication status, allowing selective route rendering</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZyEEPzA3UooPjvAJ" /><figcaption>Photo by <a href="https://unsplash.com/@dtopkin1?utm_source=medium&amp;utm_medium=referral">Dayne Topkin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><pre>const isAuthenticated = false;<br>&lt;Route path=&quot;/*&quot; element={isAuthenticated ? &lt;PrivateRoutes /&gt; : &lt;PublicRoutes /&gt;} /&gt;</pre><blockquote>Benefit:</blockquote><blockquote>When navigating between routes, only the requested pages are loaded, minimizing the initial JavaScript payload.</blockquote><h3><strong>2) Import On Interaction and Visibility</strong></h3><p>Component-level code splitting targets individual UI components, delaying their load until needed. This approach optimizes resource use by importing components only during interaction or when visible in the viewport.</p><h4>1. Import on Interaction</h4><p>This technique imports a component only when the user interacts with a specific element, like a button or a tab.</p><h4>Example:</h4><p>Suppose you have a Profile component that users rarely access and can be loaded on interaction:</p><pre>import React, { lazy, Suspense, useState } from &#39;react&#39;;<br>const Profile = lazy(() =&gt; import(&#39;./Profile&#39;));<br>export default function App() {<br>  const [showProfile, setShowProfile] = useState(false);<br>  return (<br>    &lt;div&gt;<br>      &lt;button onClick={() =&gt; setShowProfile(true)}&gt;Load Profile&lt;/button&gt;<br>      {showProfile &amp;&amp; (<br>        &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>          &lt;Profile /&gt;<br>        &lt;/Suspense&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>}</pre><p>Here, Profile loads only after the button is clicked, improving the initial load time by keeping it out of the initial bundle.</p><h4>2. Import on Visibility</h4><p>Use this technique for components only visible upon scrolling into view. react-intersection-observer is effective for visibility-based lazy loading.</p><h4>Example:</h4><p>For a Gallery component that appears only when scrolled into view:</p><pre>import React, { lazy, Suspense } from &#39;react&#39;;<br>import { useInView } from &#39;react-intersection-observer&#39;;<br>const Gallery = lazy(() =&gt; import(&#39;./Gallery&#39;));<br>export default function App() {<br>  const { ref, inView } = useInView({<br>    triggerOnce: true, // Load only once when visible<br>    threshold: 0.5, // Trigger when 50% visible<br>  });<br>  return (<br>    &lt;div&gt;<br>      &lt;div style={{ height: &#39;100vh&#39; }}&gt;Scroll down to load gallery...&lt;/div&gt;<br>      &lt;div ref={ref}&gt;<br>        {inView &amp;&amp; (<br>          &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>            &lt;Gallery /&gt;<br>          &lt;/Suspense&gt;<br>        )}<br>      &lt;/div&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><p>The Gallery component loads only when 50% of it is visible on the screen.</p><blockquote>Benefits :</blockquote><blockquote><strong>Reduced Initial Load Time</strong>: Defers loading for non-essential components.</blockquote><blockquote><strong>Better User Experience</strong>: Improves interactivity, especially for components below the fold.</blockquote><h3>3) Compression techniques like gzip and broadly</h3><ul><li><strong>Gzip and Brotli</strong> are widely supported compression techniques that reduce JavaScript file sizes by 15–25%, improving load times.</li><li><strong>Next.js</strong> uses gzip compression by default, while in React, the compression algorithm must be specified in the Webpack configuration.</li><li>Although Brotli provides better compression ratios than gzip, it might not be universally supported by all browsers.</li></ul><pre>// Sample Webpack configuration for gzip and Brotli in a React app<br>const CompressionPlugin = require(&#39;compression-webpack-plugin&#39;);<br><br>module.exports = {<br>  plugins: [<br>    new CompressionPlugin({<br>      algorithm: &#39;brotliCompress&#39;, // or &#39;gzip&#39;<br>      test: /\.(js|css|html|svg)$/,<br>      compressionOptions: { level: 11 },<br>    }),<br>  ],<br>};</pre><h3>4) Prefetching in React</h3><p><strong>Prefetching</strong> is an optimization technique where we load resources before they’re required, improving load times for resources users are likely to access next. This technique is beneficial for anticipated user actions, like navigating to the next page.</p><p><strong>React</strong> can use prefetching by leveraging &lt;link rel=&quot;prefetch&quot;&gt; or &lt;link rel=&quot;preload&quot;&gt; tags in the HTML or using libraries like react-router for component-based prefetching. Here’s how to do it:</p><ol><li><strong>Using </strong><strong>rel=&quot;prefetch&quot; and </strong><strong>rel=&quot;preload&quot; in HTML</strong></li></ol><ul><li>Add these links in your index.html file to prefetch or preload assets you expect users to need soon.</li></ul><pre>&lt;link rel=&quot;prefetch&quot; href=&quot;/path/to/next-page.js&quot;&gt;<br>&lt;link rel=&quot;preload&quot; href=&quot;/path/to/important-script.js&quot; as=&quot;script&quot;&gt;</pre><p><strong>2. Component-Based Prefetching with React Router</strong></p><ul><li>In applications with React Router, you can import pages in advance so they’re ready when a user navigates. The following example shows how to implement prefetching for specific routes:</li></ul><pre>import React, { lazy, Suspense } from &quot;react&quot;;<br>import { Switch, Route, BrowserRouter as Router } from &quot;react-router-dom&quot;;<br><br>const Home = lazy(() =&gt; import(&quot;./Home&quot;));<br>const About = lazy(() =&gt; import(/* webpackPrefetch: true */ &quot;./About&quot;));<br>const Contact = lazy(() =&gt; import(/* webpackPrefetch: true */ &quot;./Contact&quot;));<br><br>function App() {<br>  return (<br>    &lt;Router&gt;<br>      &lt;Suspense fallback={&lt;div&gt;Loading...&lt;/div&gt;}&gt;<br>        &lt;Switch&gt;<br>          &lt;Route exact path=&quot;/&quot; component={Home} /&gt;<br>          &lt;Route path=&quot;/about&quot; component={About} /&gt;<br>          &lt;Route path=&quot;/contact&quot; component={Contact} /&gt;<br>        &lt;/Switch&gt;<br>      &lt;/Suspense&gt;<br>    &lt;/Router&gt;<br>  );<br>}<br><br>export default App;</pre><h3>Preloading in React</h3><p><strong>Preloading</strong> is an optimization technique where you load critical resources (such as JavaScript, CSS, or fonts) as soon as possible, even before they’re needed, to ensure that the resources are ready when required by the user. It helps improve page load times by prioritizing essential resources over less critical ones.</p><h4>How to Implement Preloading in React</h4><p>Preloading can be done by using the &lt;link rel=&quot;preload&quot;&gt; tag in the HTML header or within React components, especially for assets like scripts, styles, and fonts.</p><pre>&lt;!-- Preload a critical JS file --&gt;<br>&lt;link rel=&quot;preload&quot; href=&quot;/path/to/critical-script.js&quot; as=&quot;script&quot;&gt;</pre><p>Preloading fonts:</p><pre>&lt;!-- Preload a custom font --&gt;<br>&lt;link rel=&quot;preload&quot; href=&quot;/path/to/font.woff2&quot; as=&quot;font&quot; type=&quot;font/woff2&quot; crossorigin=&quot;anonymous&quot;&gt;</pre><h4>Preloading Assets in Routes</h4><p>When using React Router, you can preemptively load specific route components to ensure smoother navigation. This can be done in combination with React.lazy and Suspense for lazy loading.</p><pre>const About = lazy(() =&gt; import(/* webpackPreload: true */ &#39;./About&#39;));<br>const Contact = lazy(() =&gt; import(/* webpackPreload: true */ &#39;./Contact&#39;));</pre><p>Tree Shaking in JavaScript</p><p><strong>Tree shaking</strong> is a term used to describe the process of eliminating dead code (unused code) during the build step of a JavaScript application. It helps reduce the final bundle size by ensuring that only the necessary code is included in the final output.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FSruPdSeg9kYtBNHeNr%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExajczYmh2dndrZ3V4bjF6ZTQ0M2lkOWV4b24xczE0OWMwbmJ4Mmg0MCZlcD12MV9naWZzX3NlYXJjaCZjdD1n%2FSruPdSeg9kYtBNHeNr%2Fgiphy.gif&amp;image=https%3A%2F%2Fmedia0.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaHQ1OThjazVnMHEzMWx4djQ5OG5oOWYwaG5wZXJ3cndxdDZ5eGVxeCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FSruPdSeg9kYtBNHeNr%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/02748e41ce24dc02b5833fed3f453150/href">https://medium.com/media/02748e41ce24dc02b5833fed3f453150/href</a></iframe><h4>Steps to Enable Tree Shaking</h4><h4>1. ES Module Syntax</h4><p>Tree shaking works best when your code uses <strong>ES Modules</strong> (import/export), as they allow the bundler to statically analyze the code and detect unused exports.</p><pre>// utils.js<br>export const add = (a, b) =&gt; a + b;<br>export const subtract = (a, b) =&gt; a - b;<br><br>// main.js<br>import { add } from &#39;./utils&#39;;  // Only &#39;add&#39; is imported, so &#39;subtract&#39; will be removed during tree shaking.</pre><p>2. <strong>Set Up Webpack for Tree Shaking</strong></p><p>To enable tree shaking with Webpack, you need to ensure you’re using <strong>production mode</strong> and have configured your project to support ES Modules.</p><ul><li>In your webpack.config.js, make sure the mode is set to &quot;production&quot;:</li></ul><pre>module.exports = {<br>  mode: &#39;production&#39;,<br>  // Other configurations...<br>};</pre><p>Webpack uses <strong>dead code elimination</strong> (the core of tree shaking) when the project is in production mode.</p><ul><li>Ensure your dependencies also support tree shaking. For example, many libraries provide “modular” builds that only include the necessary parts, minimizing the final bundle size.</li></ul><h4>3. Use import and export Instead of require()</h4><p>If you’re using <strong>CommonJS modules</strong> (e.g., require() and module.exports), tree shaking may not work as effectively. To take full advantage of tree shaking, you should switch to using <strong>ES Modules</strong>:</p><pre>// Bad for tree shaking<br>const { add } = require(&#39;./utils&#39;);<br><br>// Good for tree shaking<br>import { add } from &#39;./utils&#39;;</pre><p>4. <strong>Minification</strong></p><p>Tree shaking works more effectively when combined with <strong>minification</strong>. Tools like <strong>Terser</strong> (used in Webpack by default in production mode) remove unused code during the final minification step. This step can further reduce the size of your JavaScript bundle.</p><h4>Example of Tree Shaking in Action</h4><p>Let’s say you have a utility file with multiple functions:</p><pre>// utils.js<br>export const add = (a, b) =&gt; a + b;<br>export const subtract = (a, b) =&gt; a - b;<br>export const multiply = (a, b) =&gt; a * b;<br>export const divide = (a, b) =&gt; a / b;</pre><p>In your main application, you only use the add function:</p><pre>// app.js<br>import { add } from &#39;./utils&#39;;<br><br>console.log(add(5, 3));</pre><blockquote>Conclusion</blockquote><blockquote>Optimizing JavaScript performance is key to faster, more efficient applications. Techniques like <strong>code splitting</strong>, <strong>compression (gzip/Brotli)</strong>, <strong>prefetching</strong>, <strong>preloading</strong>, and <strong>tree shaking</strong> help reduce file sizes, improve load times, and enhance user experience. By implementing these strategies, you can create faster, more responsive apps with improved efficiency and better user satisfaction.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1689f6970481" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Basics You Thought You Knew: Uncovering Web Development Fundamentals]]></title>
            <link>https://medium.com/@khushi1399gupta/the-basics-you-thought-you-knew-uncovering-web-development-fundamentals-360012cf9d53?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/360012cf9d53</guid>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[mastering]]></category>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[learning-and-development]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Fri, 26 Jul 2024 12:04:27 GMT</pubDate>
            <atom:updated>2024-07-26T12:04:27.243Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>Think you know the basics of web development? Think again! In this blog, we uncover the hidden gems of foundational concepts that are often misunderstood or overlooked.</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FIOUn2qgyH54tH90uJ8%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FIOUn2qgyH54tH90uJ8%2Fgiphy.gif%3Fcid%3D790b7611qua4mu46kz6qooo8be3hdubbnz5cc0xwsr6rm2nj%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia2.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExOGdwNGFzbGludHBtcXZsaG1jNjVxbHE0cnBkZTdtN3N6cmFreWVucyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FIOUn2qgyH54tH90uJ8%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="248" frameborder="0" scrolling="no"><a href="https://medium.com/media/4392a786bc61384c2fd3e454ae6e9111/href">https://medium.com/media/4392a786bc61384c2fd3e454ae6e9111/href</a></iframe><h3>Difference Between React and ReactDOM</h3><ul><li><strong>React:</strong> Focuses on the core functionality of building UI components.</li><li><strong>ReactDOM:</strong> Specifically deals with rendering these components to the DOM in web applications.</li><li><strong>Separation of Concerns:</strong> Discuss how React handles the logic and structure, while ReactDOM handles the browser-related parts.</li></ul><h3>What is CDN? Why Do We Use It?</h3><ul><li><strong>Definition:</strong> CDN (Content Delivery Network) is a network of servers that deliver content to users based on their geographic location.</li><li><strong>Benefits:</strong> Explain benefits such as reduced latency, faster load times, and load distribution across servers.</li><li><strong>Use Case in React:</strong> Discuss how CDNs can be used to serve React libraries like react and react-dom efficiently.</li></ul><h3><strong>What is Emmet ?</strong></h3><p><strong>Definition:</strong> Emmet is a plugin for popular text editors like VS Code, Sublime Text, and Atom that enhances HTML and CSS workflows.</p><p><strong>Usage:</strong> Emmet provides shorthand abbreviations to quickly generate complex HTML/CSS code, speeding up development.</p><p><strong>Example:</strong></p><ul><li><strong>Abbreviation:</strong> ul&gt;li*5</li></ul><pre>&lt;ul&gt;<br>  &lt;li&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;/li&gt;<br>  &lt;li&gt;&lt;/li&gt;<br>&lt;/ul&gt;</pre><h3>What is crossorigin in Script Tags?</h3><ul><li><strong>Purpose:</strong> The crossorigin attribute is used to handle CORS (Cross-Origin Resource Sharing) settings for script requests.</li><li><strong>Usage in React Projects:</strong> Explains when and why you might use the crossorigin attribute when loading scripts, such as from a CDN.</li></ul><h3>Difference Between dependencies and devDependencies</h3><p>In JavaScript projects, especially those managed by Node.js and npm (Node Package Manager), dependencies are divided into two main categories: dependencies and devDependencies.</p><p><strong>Dependencies (</strong><strong>dependencies):</strong></p><ul><li><strong>Definition:</strong> These are packages that your project needs to run in production. They are essential for the application to function.</li><li><strong>Installation:</strong> When you install a package using npm install &lt;package-name&gt; --save, it gets added to the dependencies section of your package.json file.</li><li><strong>Examples:</strong> Frameworks and libraries like React, Axios, or Lodash that are used directly in your application code.</li></ul><p><strong>DevDependencies (</strong><strong>devDependencies):</strong></p><ul><li><strong>Definition:</strong> These are packages that are only needed during the development phase of your project. They are not required in the production environment.</li><li><strong>Installation:</strong> Installing a package with npm install &lt;package-name&gt; --save-dev adds it to the devDependencies section.</li><li><strong>Examples:</strong> Tools like webpack, Babel, ESLint, and testing libraries like Jest or Mocha.</li></ul><h3>What is Tree Shaking?</h3><p>Tree shaking is a term used in the context of JavaScript bundlers (like webpack) to describe the process of eliminating dead code.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FjtivPQNiU7MiOLg2ke%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FjtivPQNiU7MiOLg2ke%2Fgiphy.gif%3Fcid%3D790b7611l0hr8u5mpaz8gnk22y0pwkcvksj6qcgy0t0q4o9o%26ep%3Dv1_gifs_search%26rid%3Dgiphy.gif%26ct%3Dg&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExaTJqYzZ6ZzAzYWluZmkxcGlnNjBuaXE2Ynp2Z3Rkb2ZxaHJybXpqbSZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2FjtivPQNiU7MiOLg2ke%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="246" frameborder="0" scrolling="no"><a href="https://medium.com/media/bbb3fd8588c15f552121789ce7a326d8/href">https://medium.com/media/bbb3fd8588c15f552121789ce7a326d8/href</a></iframe><ul><li><strong>Definition:</strong> Tree shaking is a technique that removes unused code from the final bundle, reducing the overall size of the application and improving load times.</li><li><strong>How It Works:</strong> It leverages ES6 (ECMAScript 2015) module syntax, where import and export statements are static, meaning they are known at compile time. This allows bundlers to analyze and exclude code that is not used.</li><li><strong>Example:</strong> If you import a utility library but only use one function from it, tree shaking ensures that only that function is included in the final bundle, and the rest is removed</li></ul><h4>What is Hot Module Replacement (HMR)?</h4><p>Hot Module Replacement is a feature provided by some module bundlers, such as webpack, that allows modules to be updated in place without requiring a full page reload.</p><h3>What is Reconciliation in React?</h3><p>Reconciliation is a process used by React to update the user interface (UI) efficiently when the state of an application changes. The core of React’s reconciliation process involves updating the virtual DOM (a lightweight in-memory representation of the actual DOM) and then efficiently updating the real DOM to reflect the changes.</p><h4>Why Reconciliation Matters:</h4><ul><li>Reconciliation allows React to update the UI in a performant and predictable manner. By only making the necessary updates to the DOM, React ensures that applications are responsive and maintain a smooth user experience.</li></ul><h3>What is Shimmer UI?</h3><p><strong>Shimmer UI</strong> is a design pattern used to indicate that content is loading or will be available shortly. It provides a visual placeholder that mimics the layout of the expected content, usually with a gradient or animated effect that simulates the appearance of data “shimmering” into view. This technique enhances the user experience</p><blockquote>This is not the representation of Shimmer UI but I though to put some shimmer in your view</blockquote><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F3d63YDxRJRtkZepvGm%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F3d63YDxRJRtkZepvGm%2Fgiphy.gif%3Fcid%3D790b7611ee6koehndus652lpd4ls1eayqeoolq26mmbbhmku%26ep%3Dv1_internal_gif_by_id%26ct%3Dg&amp;image=https%3A%2F%2Fmedia1.giphy.com%2Fmedia%2Fv1.Y2lkPTc5MGI3NjExdmo5ejZhcGFmaW83ZHF3cDBubzlhMXN4aWwxdDY3czd4eTl6bGsxcyZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw%2F3d63YDxRJRtkZepvGm%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="244" frameborder="0" scrolling="no"><a href="https://medium.com/media/4e4889619743adeb7049a3e7a4ba2482/href">https://medium.com/media/4e4889619743adeb7049a3e7a4ba2482/href</a></iframe><h3>Difference Between JS Expression and JS Statement</h3><h4>JS Expression:</h4><p>An <strong>expression</strong> in JavaScript is any valid unit of code that resolves to a value. Expressions can be simple or complex and include values, variables, operators, and function invocations.</p><ul><li><strong>Examples of Expressions:</strong></li><li>2 + 2 (resolves to 4)</li></ul><h4>JS Statement:</h4><p>A <strong>statement</strong> in JavaScript is a piece of code that performs an action. Statements are the building blocks of a JavaScript program and define the actions the program takes.</p><ul><li><strong>Examples of Statements:</strong></li><li>let x = 5; (declaration and assignment statement)</li></ul><h3>What is a Meta Tag?</h3><p>A meta tag is an HTML tag that provides metadata about the HTML document. Metadata is data about data, and in this case, it provides information about the page’s content, character encoding, author, and more.</p><h3><strong>What is Server-Side Rendering (SSR) and Client-Side Rendering (CSR)</strong></h3><ul><li><strong>Definition:</strong> SSR generates HTML on the server, while CSR generates it on the client.</li><li><strong>Benefits:</strong> Understanding the differences helps in choosing the right rendering method for performance and SEO.</li></ul><blockquote><em>Understanding these fundamental concepts not only sharpens your development skills but also equips you with the knowledge to tackle complex challenges with confidence. Whether you’re refining your existing knowledge or exploring new aspects, mastering these basics is key to becoming a more effective and insightful web developer.</em></blockquote><p>Happy learning ……….</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=360012cf9d53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[15 Libraries You Should Know if You Build with React]]></title>
            <link>https://medium.com/@khushi1399gupta/15-libraries-you-should-know-if-you-build-with-react-088d7bb110e8?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/088d7bb110e8</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[should-know-about]]></category>
            <category><![CDATA[begginer]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[library-design]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Thu, 11 Apr 2024 05:43:24 GMT</pubDate>
            <atom:updated>2024-04-11T05:43:24.165Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction to React</h3><p>In the world of modern web development, React stands out as a powerful and versatile library for building user interfaces. Developed by Meta (formerly Facebook), React has gained immense popularity among developers and is widely used in various applications.</p><h3>What is React?</h3><p>React is a free and open-source front-end JavaScript library that simplifies the process of building dynamic and interactive user interfaces. It adopts a component-based architecture, allowing developers to create reusable UI components that can be composed together to build complex applications.</p><h3>React in Action</h3><p>React is widely used in the development of popular websites and web applications, including:</p><ul><li>Facebook</li><li>Instagram</li><li>Netflix</li><li>Airbnb</li><li>Twitter</li><li>WhatsApp Web</li><li>Pinterest</li><li>Twitch</li></ul><h3>Exploring React Libraries</h3><h3>What is a Library?</h3><p>In coding, a library refers to a collection of pre-written code that developers can leverage to simplify and expedite their programming tasks. These libraries provide reusable functionality that can be integrated into different applications, reducing development time and effort.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*1p_bsCg0TjR_H3VC" /><figcaption>Liberary will help you in less coding and effort</figcaption></figure><h3>Essential Libraries for React Development</h3><h3>1. Axios</h3><pre>npm i axios</pre><p>Axios is a simple promise based HTTP client for the browser and node.js. Axios provides a simple-to-use library in a small package with a very extensible interface.</p><pre>async function getUser() {<br>  try {<br>    const response = await axios.get(&#39;/user?ID=12345&#39;);<br>    console.log(response);<br>  } catch (error) {<br>    console.error(error);<br>  }<br>}</pre><p>Instead of using Fetch we can use Axios and reduce the line of code by hitting API with the Axios library</p><h4>2. Formik:</h4><p>Formik is a free, open-source library that helps build and process form data in React applications. It provides a simple API and built-in validation, making it easy to collect and manipulate input data. Formik is used by companies like Airbnb, Walmart, Lyft, and Stripe.</p><pre>npm i formik</pre><pre>import React from &#39;react&#39;;<br>import { Formik, Form, Field, ErrorMessage } from &#39;formik&#39;;<br><br>const initialValues = {<br>  firstName: &#39;&#39;,<br>  lastName: &#39;&#39;,<br>  email: &#39;&#39;,<br>};<br><br>const onSubmit = (values) =&gt; {<br>  console.log(values);<br>};<br><br>const validate = (values) =&gt; {<br>  const errors = {};<br><br>  if (!values.firstName) {<br>    errors.firstName = &#39;Required&#39;;<br>  }<br><br>  if (!values.lastName) {<br>    errors.lastName = &#39;Required&#39;;<br>  }<br><br>  if (!values.email) {<br>    errors.email = &#39;Required&#39;;<br>  } else if (!/^\S+@\S+\.\S+$/.test(values.email)) {<br>    errors.email = &#39;Invalid email address&#39;;<br>  }<br><br>  return errors;<br>};<br><br>const SampleForm = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Sample Form&lt;/h1&gt;<br>      &lt;Formik<br>        initialValues={initialValues}<br>        onSubmit={onSubmit}<br>        validate={validate}<br>      &gt;<br>        {({ isSubmitting }) =&gt; (<br>          &lt;Form&gt;<br>            &lt;div&gt;<br>              &lt;label htmlFor=&quot;firstName&quot;&gt;First Name:&lt;/label&gt;<br>              &lt;Field type=&quot;text&quot; id=&quot;firstName&quot; name=&quot;firstName&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;firstName&quot; component=&quot;div&quot; /&gt;<br>            &lt;/div&gt;<br><br>            &lt;div&gt;<br>              &lt;label htmlFor=&quot;lastName&quot;&gt;Last Name:&lt;/label&gt;<br>              &lt;Field type=&quot;text&quot; id=&quot;lastName&quot; name=&quot;lastName&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;lastName&quot; component=&quot;div&quot; /&gt;<br>            &lt;/div&gt;<br><br>            &lt;div&gt;<br>              &lt;label htmlFor=&quot;email&quot;&gt;Email:&lt;/label&gt;<br>              &lt;Field type=&quot;email&quot; id=&quot;email&quot; name=&quot;email&quot; /&gt;<br>              &lt;ErrorMessage name=&quot;email&quot; component=&quot;div&quot; /&gt;<br>            &lt;/div&gt;<br><br>            &lt;button type=&quot;submit&quot; disabled={isSubmitting}&gt;<br>              Submit<br>            &lt;/button&gt;<br>          &lt;/Form&gt;<br>        )}<br>      &lt;/Formik&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default SampleForm;</pre><p><em>Formik simplifies form validation in React applications by providing an intuitive API for managing form state and validation logic.</em></p><h4>3. React Helmet</h4><p>React Helmet, for instance, can be used to dynamically set the document’s title, description, and meta tags. This comes in very handy when you need to update the meta tags for SEO. React Helmet supports all valid head tags, including title, style, base, meta, link, script, and NoScript.</p><pre>npm i react-helmet</pre><pre>import React from &quot;react&quot;;<br>import {Helmet} from &quot;react-helmet&quot;;<br><br>class Application extends React.Component {<br>  render () {<br>    return (<br>        &lt;div className=&quot;application&quot;&gt;<br>            &lt;Helmet&gt;<br>                &lt;meta charSet=&quot;utf-8&quot; /&gt;<br>                &lt;title&gt;My Title&lt;/title&gt;<br>                &lt;link rel=&quot;canonical&quot; href=&quot;http://mysite.com/example&quot; /&gt;<br>            &lt;/Helmet&gt;<br>            ...<br>        &lt;/div&gt;<br>    );<br>  }<br>};</pre><p>React Helmet can help you improve the SEO of your website by making it easier to set and update the meta tags that search engines use to index and rank your pages. By providing accurate and up-to-date information about your content, you can help search engines understand your website better and improve your ranking in search results.</p><p>React Helmet can also help you enhance the social media sharing of your website by making it easier to set and update the meta tags that social media platforms use to display your content when it is shared.</p><h4>4. React -Redux:</h4><p>Redux is a JS library for predictable and maintainable global state management.</p><pre>npm i react-redux</pre><p>Basic Example of React-Redux</p><pre>import React from &#39;react&#39;;<br>import { createStore } from &#39;redux&#39;;<br>import { Provider, connect } from &#39;react-redux&#39;;<br><br>// Define the initial state<br>const initialState = {<br>  count: 0<br>};<br><br>// Define reducer function<br>const reducer = (state = initialState, action) =&gt; {<br>  switch (action.type) {<br>    case &#39;INCREMENT&#39;:<br>      return {<br>        ...state,<br>        count: state.count + 1<br>      };<br>    case &#39;DECREMENT&#39;:<br>      return {<br>        ...state,<br>        count: state.count - 1<br>      };<br>    default:<br>      return state;<br>  }<br>};<br><br>// Create the Redux store<br>const store = createStore(reducer);<br><br>// Define action creators<br>const increment = () =&gt; ({ type: &#39;INCREMENT&#39; });<br>const decrement = () =&gt; ({ type: &#39;DECREMENT&#39; });<br><br>// Counter component<br>const Counter = ({ count, increment, decrement }) =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Counter: {count}&lt;/h1&gt;<br>      &lt;button onClick={increment}&gt;Increment&lt;/button&gt;<br>      &lt;button onClick={decrement}&gt;Decrement&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>// Connect Counter component to Redux store<br>const ConnectedCounter = connect(<br>  state =&gt; ({ count: state.count }),<br>  { increment, decrement }<br>)(Counter);<br><br>// App component<br>const App = () =&gt; {<br>  return (<br>    &lt;Provider store={store}&gt;<br>      &lt;ConnectedCounter /&gt;<br>    &lt;/Provider&gt;<br>  );<br>};<br><br>export default App;</pre><p>The whole global state of your app is stored in an object tree inside a single <em>store</em>. The only way to change the state tree is to create an <em>action</em>, an object describing what happened, and <em>dispatch</em> it to the store. To specify how a state gets updated in response to an action, you write pure <em>reducer</em> functions that calculate a new state based on the old state and the action.</p><h4>5. React Router DOM</h4><pre>npm i react-router-dom</pre><p>React Router Dom is commonly used for routing and managing navigation in web applications built using React. It simplifies the routing process by providing an API to define, navigate, and render routes.</p><pre>import * as React from &quot;react&quot;;<br>import * as ReactDOM from &quot;react-dom/client&quot;;<br>import {<br>  createBrowserRouter,<br>  RouterProvider,<br>} from &quot;react-router-dom&quot;;<br>import &quot;./index.css&quot;;<br><br>const router = createBrowserRouter([<br>  {<br>    path: &quot;/&quot;,<br>    element: &lt;div&gt;Hello world!&lt;/div&gt;,<br>  },<br>]);<br><br>ReactDOM.createRoot(document.getElementById(&quot;root&quot;)).render(<br>  &lt;React.StrictMode&gt;<br>    &lt;RouterProvider router={router} /&gt;<br>  &lt;/React.StrictMode&gt;<br>);</pre><p>The major advantage of react-router is that the page does not have to be refreshed when a link to another page is clicked…</p><h4>6. Dotenv:</h4><pre>npm install dotenv --save</pre><p>Dotenv is a zero-dependency module that loads environment variables from a .env file into <a href="https://nodejs.org/docs/latest/api/process.html#process_process_env">process.env</a>. Storing configuration in the environment separate from the codebase to secure the keys and information that should be kept confidential like passwords and secret key</p><pre>import React, { useEffect, useState } from &#39;react&#39;;<br>require(&#39;dotenv&#39;).config();<br><br>const App = () =&gt; {<br>  const [data, setData] = useState(null);<br><br>  useEffect(() =&gt; {<br>    // Fetch data from the API using the environment variable<br>    fetch(process.env.REACT_APP_API_URL)<br>      .then(response =&gt; response.json())<br>      .then(data =&gt; setData(data))<br>      .catch(error =&gt; console.error(&#39;Error fetching data:&#39;, error));<br>  }, []);<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;Data from API&lt;/h1&gt;<br>      {data ? (<br>        &lt;pre&gt;{JSON.stringify(data, null, 2)}&lt;/pre&gt;<br>      ) : (<br>        &lt;p&gt;Loading...&lt;/p&gt;<br>      )}<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default App;</pre><h4>7. esLint</h4><pre>npm i eslint</pre><p>ESLint is a popular open-source JavaScript linting utility. It analyzes your code for potential errors, enforces coding standards, and improves code quality. ESLint can also help you as a developer to identify and fix common mistakes, use best practices, and maintain consistency across your codebase.</p><p>Basic example</p><pre>import js from &quot;@eslint/js&quot;;<br><br>export default [<br>    js.configs.recommended,<br><br>   {<br>       rules: {<br>           &quot;no-unused-vars&quot;: &quot;warn&quot;,<br>           &quot;no-undef&quot;: &quot;warn&quot;<br>       }<br>   }<br>];</pre><pre>import React from &#39;react&#39;;<br>import Header from &#39;./components/Header&#39;;const App = () =&gt; {<br>    return (<br>        &lt;div&gt;<br>            &lt;Header /&gt;<br>        &lt;/div&gt;<br>    );<br>};export default App;</pre><p>As you can see, all we want to do is to render that one component. But if we run eslinton this file, we&#39;ll get a couple of errors.</p><pre>1:8  warning  &#39;React&#39; is defined but never used   no-unused-vars<br>2:8  warning  &#39;Header&#39; is defined but never used  no-unused-vars</pre><h4>8. date-fns</h4><pre>npm i date-fns</pre><p>date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser &amp; Node.js.</p><pre>// Parse a date string<br>const date = dateFns.parse(&#39;2023-08-04&#39;);<br><br>// Format a date<br>const formattedDate = dateFns.format(date, &#39;MM/dd/yyyy&#39;);<br><br>// Compare two dates<br>const areDatesEqual = dateFns.isEqual(date1, date2);<br><br>// Calculate the difference between two dates<br>const differenceInDays = dateFns.differenceInDays(date1, date2);</pre><p>Date-fns is a powerful and versatile library for working with dates and times in JavaScript. It is a great choice for projects of all sizes.</p><h4>9. react-error-boundaries</h4><pre>npm install react-error-boundary</pre><p>Error boundaries are React components that catch JavaScript errors anywhere in their child component tree, log those errors, and display a fallback UI instead of the component tree that crashed</p><p><em>The component supports several ways to render a fallback (as shown below).</em></p><pre>&quot;use client&quot;;<br><br>import { ErrorBoundary } from &quot;react-error-boundary&quot;;<br><br>function fallbackRender({ error, resetErrorBoundary }) {<br>  // Call resetErrorBoundary() to reset the error boundary and retry the render.<br><br>  return (<br>    &lt;div role=&quot;alert&quot;&gt;<br>      &lt;p&gt;Something went wrong:&lt;/p&gt;<br>      &lt;pre style={{ color: &quot;red&quot; }}&gt;{error.message}&lt;/pre&gt;<br>    &lt;/div&gt;<br>  );<br>}<br><br>&lt;ErrorBoundary<br>  fallbackRender={fallbackRender}<br>  onReset={(details) =&gt; {<br>    // Reset the state of your app so the error doesn&#39;t happen again<br>  }}<br>&gt;<br>  &lt;ExampleApplication /&gt;<br>&lt;/ErrorBoundary&gt;;</pre><p>Wrap an ErrorBoundary component around other React components to &quot;catch&quot; errors and render a fallback UI (<em>A fallback UI is a temporary UI that renders in place of the actual UI when it hasn’t finished loading</em>).</p><h4>10. sweetalert</h4><pre>npm install sweetalert --save</pre><p>SweetAlert is a JavaScript library that provides alternative alert and modal dialog boxes for web applications. It can replace built-in alert functions and improve the user interface of default browser dialogs.</p><pre>import React from &#39;react&#39;;<br>import Swal from &#39;sweetalert&#39;;<br><br>const SweetAlertExample = () =&gt; {<br>  const handleClick = () =&gt; {<br>    Swal.fire({<br>      title: &#39;Hello!&#39;,<br>      text: &#39;This is a SweetAlert dialog.&#39;,<br>      icon: &#39;success&#39;,<br>      confirmButtonText: &#39;OK&#39;<br>    });<br>  };<br><br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;SweetAlert Example&lt;/h1&gt;<br>      &lt;button onClick={handleClick}&gt;Show SweetAlert&lt;/button&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default SweetAlertExample;</pre><h4>11. styled-components</h4><pre>npm i styled-components</pre><p>Styled-components is an open-source library that allows React and React Native developers to define UI components and styles in a single file location. It uses CSS in JavaScript (JS), which allows developers to write CSS code directly in the JavaScript file.</p><pre>import React from &#39;react&#39;;<br><br>import styled from &#39;styled-components&#39;;<br><br>// Create a &lt;Title&gt; react component that renders an &lt;h1&gt; which is<br>// centered, palevioletred and sized at 1.5em<br>const Title = styled.h1`<br>  font-size: 1.5em;<br>  text-align: center;<br>  color: palevioletred;<br>`;<br><br>// Create a &lt;Wrapper&gt; react component that renders a &lt;section&gt; with<br>// some padding and a papayawhip background<br>const Wrapper = styled.section`<br>  padding: 4em;<br>  background: papayawhip;<br>`;<br><br>function MyUI() {<br>  return (<br>    // Use them like any other React component – except they&#39;re styled!<br>    &lt;Wrapper&gt;<br>      &lt;Title&gt;Hello World, this is my first styled component!&lt;/Title&gt;<br>    &lt;/Wrapper&gt;<br>  );<br>}</pre><h4>12. react-tooltip</h4><pre>npm install react-tooltip</pre><p>The react-tooltip package provides a &lt;Tooltip/&gt; component that can be bound to an anchor element and used to display element-specific information.</p><pre>import React from &#39;react&#39;;<br>import ReactTooltip from &#39;react-tooltip&#39;;<br><br>const TooltipExample = () =&gt; {<br>  return (<br>    &lt;div&gt;<br>      &lt;h1&gt;React Tooltip Example&lt;/h1&gt;<br>      &lt;button data-tip=&quot;Hello, I am a tooltip!&quot; data-for=&quot;tooltip&quot;&gt;Hover me&lt;/button&gt;<br>      &lt;ReactTooltip id=&quot;tooltip&quot; place=&quot;bottom&quot; effect=&quot;solid&quot; /&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default TooltipExample;</pre><h4>13. React Spinner</h4><pre>npm install --save react-spinners</pre><p>react-spinner-loader provides a simple React SVG spinner component which can be implemented for async-await operation before data loads to the view.</p><pre>import React from &#39;react&#39;;<br>import { css } from &#39;@emotion/react&#39;;<br>import { RingLoader } from &#39;react-spinners&#39;;<br><br>const override = css`<br>  display: block;<br>  margin: 0 auto;<br>  border-color: red;<br>`;<br><br>const SpinnerExample = () =&gt; {<br>  return (<br>    &lt;div className=&quot;sweet-loading&quot;&gt;<br>      &lt;RingLoader color={&#39;#123abc&#39;} css={override} size={150} loading={true} /&gt;<br>    &lt;/div&gt;<br>  );<br>};<br><br>export default SpinnerExample;</pre><h4>14. Yup</h4><pre>npm i yup</pre><p>Yup is a schema builder for runtime value parsing and validation. Define a schema, transform a value to match, assert the shape of an existing value, or both. Yup, schema are extremely expressive and allows modeling complex, interdependent validations, or value transformation.</p><pre>import * as yup from &#39;yup&#39;;<br><br>const personSchema = yup.object({<br>  firstName: yup.string().defined(),<br>  nickName: yup.string().default(&#39;&#39;).nullable(),<br>  sex: yup<br>    .mixed()<br>    .oneOf([&#39;male&#39;, &#39;female&#39;, &#39;other&#39;] as const)<br>    .defined(),<br>  email: yup.string().nullable().email(),<br>  birthDate: yup.date().nullable().min(new Date(1900, 0, 1)),<br>});</pre><h3>15. @testing-library/jest-dom</h3><pre>npm install --save-dev @testing-library/jest-dom</pre><p>@testing-library/jest-dom is a library that provides custom matchers to test the state of the DOM. It’s an extension for the Jest testing framework that enables assertions on DOM elements, attributes, and content.</p><pre>&lt;button data-testid=&quot;button&quot; type=&quot;submit&quot; disabled&gt;submit&lt;/button&gt;<br>&lt;fieldset disabled&gt;&lt;input type=&quot;text&quot; data-testid=&quot;input&quot; /&gt;&lt;/fieldset&gt;<br>&lt;a href=&quot;...&quot; disabled&gt;link&lt;/a&gt;</pre><pre>expect(getByTestId(&#39;button&#39;)).toBeDisabled()<br>expect(getByTestId(&#39;input&#39;)).toBeDisabled()<br>expect(getByText(&#39;link&#39;)).not.toBeDisabled()</pre><h4>Conclusion</h4><blockquote>By leveraging these libraries, developers can enhance the functionality, performance, and user experience of their React applications while reducing development time and effort.</blockquote><blockquote>Overall, this comprehensive overview provides valuable insights into the ecosystem of tools and libraries available for React development, empowering developers to build robust and feature-rich applications effectively.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=088d7bb110e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Only coding doesn’t take you far in your career, here’s what else you need to learn to become a 1%…]]></title>
            <link>https://medium.com/@khushi1399gupta/only-coding-doesnt-take-you-far-in-your-career-here-s-what-else-you-need-to-learn-to-become-a-1-e6d1a493540c?source=rss-441cba8b191f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6d1a493540c</guid>
            <category><![CDATA[learning-and-development]]></category>
            <category><![CDATA[developement]]></category>
            <category><![CDATA[earn]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[learn]]></category>
            <dc:creator><![CDATA[Khushi_developer]]></dc:creator>
            <pubDate>Sun, 03 Mar 2024 06:18:29 GMT</pubDate>
            <atom:updated>2024-03-03T06:18:29.816Z</atom:updated>
            <content:encoded><![CDATA[<h3>Only coding doesn’t take you far in your career, here’s what else you need to learn to become a 1% developer.</h3><p><strong>Writing code is only 40–60% of a Software Developer’s job.</strong></p><blockquote>Only coding doesn’t take you far in your career, here’s what else you need to learn to become a 1% developer.</blockquote><p>-becoming a team player<br>-building relationships at work<br>-being solid at communication<br>-looking for new opportunities<br>-building problem solving mindset<br>-How to Google properly and learn<br>-in-depth software &amp; system design<br>-take feedback positively to improve<br>-knowledge of code generation tools<br>-code analysis and proper debugging<br>-adding, unit, integration and end-to-end test cases</p><h4>I can teach you to code. <br>Youtube can teach you to code. <br>Leetcode can teach you to code.</h4><h4>Yes, you need to be able to code.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CT8hXJ4xbibMN92A" /><figcaption>Photo by <a href="https://unsplash.com/@ffstop?utm_source=medium&amp;utm_medium=referral">Fotis Fotopoulos</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>But, being a good Software Engineer is much more than your coding ability.</p><p>Not everyone can solve problems, commit to being a team player, and look to better opportunities in the future.</p><p>Good work ethics and that proper mindset is much harder to teach.</p><blockquote>Learn to code and do it well, but don’t underestimate other skills too, they matter and will make your career.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6d1a493540c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>