<?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 Ali Ashraf on Medium]]></title>
        <description><![CDATA[Stories by Ali Ashraf on Medium]]></description>
        <link>https://medium.com/@m.ali.ashraf.moh?source=rss-0028d5320505------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*kpMAiUatTAq-cP3ao6vzUA.png</url>
            <title>Stories by Ali Ashraf on Medium</title>
            <link>https://medium.com/@m.ali.ashraf.moh?source=rss-0028d5320505------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:35:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@m.ali.ashraf.moh/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[How I Reduced a 3-Second API to Under 200ms by Rewriting a MongoDB Query Pipeline]]></title>
            <link>https://medium.com/@m.ali.ashraf.moh/how-i-reduced-a-3-second-api-to-under-200ms-by-rewriting-a-mongodb-query-pipeline-6ffce2cfc5e7?source=rss-0028d5320505------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ffce2cfc5e7</guid>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[mongodb]]></category>
            <dc:creator><![CDATA[Ali Ashraf]]></dc:creator>
            <pubDate>Wed, 28 Jan 2026 23:48:25 GMT</pubDate>
            <atom:updated>2026-01-28T23:48:25.425Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1LMsI9olNdagZV2CIAc1cA.png" /></figure><p>Performance issues don’t always appear as errors or alerts. Sometimes, they surface as frustrated users — especially those in <strong>congested areas</strong>, on <strong>throttled networks</strong>, or using slow 3G/4G connections in signal-dead zones like warehouses — waiting while large JSON payloads slowly load</p><p>This article explains how I optimized a <strong>MongoDB-backed Node.js API</strong>, reducing response time from <strong>~3 seconds to under 200ms</strong>, and shrinking the payload size from <strong>~25MB to ~25KB</strong>, simply by redesigning how data was fetched and shaped.</p><p>This improvement came from <strong>query architecture and data modeling</strong>, not caching.</p><h3>The Original Problem</h3><p>The API endpoint aggregated data from multiple MongoDB collections and a relational database, including:</p><ul><li>Primary records</li><li>Associated analytical data</li><li>User-related metadata</li><li>Organizational hierarchy</li><li>Permission-based access rules</li></ul><h3>Observed Symptoms</h3><ul><li>⏱️ ~3s response time</li><li>📦 ~25MB API responses</li><li>📱 Poor performance on mobile networks</li><li>🔥 High memory usage in Node.js</li><li>🧠 Heavy use of Mongoose .populate()</li></ul><h3>The Original Implementation</h3><p>The original approach relied on <strong>Mongoose </strong><strong>.find() with </strong><strong>.populate()</strong>, which abstracts joins but hides performance costs.</p><h3>Simplified Example</h3><pre>await sample_A.find({<br>  orgRef: orgId,<br>  isActive: true,<br>})<br>.populate([&quot;sample_B&quot;, &quot;sample_C&quot;, &quot;sample_D&quot;])<br>.exec();</pre><h3>Why This Did Not Scale</h3><ol><li><strong>Over-fetching</strong></li></ol><ul><li>Entire documents were loaded when only a small subset of fields was required.</li><li>Large media and metadata fields were transferred unnecessarily.</li></ul><p><strong>2. Unrestricted Population</strong></p><ul><li>.populate() pulled full documents from related collections.</li><li>No database-level filtering of nested data.</li></ul><p><strong>3. Late Filtering</strong></p><ul><li>Business rules were applied after fetching all data.</li><li>Node.js processed data MongoDB could handle more efficiently.</li></ul><p><strong>4. Network Bottleneck</strong></p><ul><li>Large payloads severely impacted users on slow connections.</li></ul><h3>Optimization Strategy</h3><p>The key realization was:</p><blockquote><strong><em>MongoDB should filter and shape data; Node.js should orchestrate, not process.</em></strong></blockquote><p>Instead of:</p><ul><li>Fetching everything</li><li>Populating everything</li><li>Filtering in application memory</li></ul><p>The solution was:</p><ul><li>Filter early</li><li>Join selectively</li><li>Project only required fields</li><li>Minimize data sent over the network</li></ul><h3>The New Approach: Aggregation Pipeline</h3><p>The .find() + .populate() pattern was replaced with a <strong>single MongoDB aggregation pipeline</strong>, providing full control over joins and payload size.</p><h3>Optimized Query (Fully Anonymized)</h3><pre>const result = await sample_A.aggregate([<br>  {<br>    $match: {<br>      orgRef: new ObjectId(orgId),<br>      isActive: true,<br>      ...(hasElevatedAccess ? {} : { createdBy: userId }),<br>    },<br>  },<br>// Remove heavy fields early<br>  {<br>    $project: {<br>      largeBlobPath: 0,<br>      largeBlobSize: 0,<br>      rawMetadata: 0,<br>      recordingTimestamp: 0,<br>    },<br>  },<br>  // Join analytical data (sample_B)<br>  {<br>    $lookup: {<br>      from: &quot;sample_B&quot;,<br>      localField: &quot;_id&quot;,<br>      foreignField: &quot;parentId&quot;,<br>      as: &quot;sample_B&quot;,<br>    },<br>  },<br>  // Keep only records with required analytics<br>  {<br>    $match: {<br>      sample_B: {<br>        $elemMatch: {<br>          metrics: { $exists: true, $type: &quot;array&quot;, $ne: [] },<br>        },<br>      },<br>    },<br>  },<br>  // Join user metadata (sample_C)<br>  {<br>    $lookup: {<br>      from: &quot;sample_C&quot;,<br>      localField: &quot;userRef&quot;,<br>      foreignField: &quot;_id&quot;,<br>      as: &quot;sample_C&quot;,<br>    },<br>  },<br>  {<br>    $unwind: {<br>      path: &quot;$sample_C&quot;,<br>      preserveNullAndEmptyArrays: true,<br>    },<br>  },<br>  // Join organizational structure (sample_D)<br>  {<br>    $lookup: {<br>      from: &quot;sample_D&quot;,<br>      localField: &quot;unitRef&quot;,<br>      foreignField: &quot;_id&quot;,<br>      as: &quot;sample_D&quot;,<br>    },<br>  },<br>  {<br>    $unwind: {<br>      path: &quot;$sample_D&quot;,<br>      preserveNullAndEmptyArrays: true,<br>    },<br>  },<br>  // Final projection<br>  {<br>    $project: {<br>      _id: 1,<br>      title: 1,<br>      category: 1,<br>      createdAt: 1,<br>      duration: 1,<br>      roleLabel: 1,<br>      &quot;sample_B._id&quot;: 1,<br>      &quot;sample_B.parentId&quot;: 1,<br>      &quot;sample_B.metrics&quot;: 1,<br>      &quot;sample_B.status&quot;: 1,<br>      &quot;sample_C._id&quot;: 1,<br>      &quot;sample_C.displayName&quot;: 1,<br>      &quot;sample_C.email&quot;: 1,<br>      &quot;sample_D._id&quot;: 1,<br>      &quot;sample_D.name&quot;: 1,<br>      &quot;sample_D.parent&quot;: 1,<br>    },<br>  },<br>]);</pre><h3>Why This Worked</h3><h3>1. Massive Payload Reduction</h3><p>MetricBeforeAfterPayload size~25MB~25KBRecords transferredAll activeOnly relevantNested arraysUnfilteredFiltered</p><p>This made the API usable even on slow mobile networks.</p><h3>2. Database-Level Optimization</h3><ul><li>Filtering executed inside MongoDB</li><li>Node.js handled orchestration only</li><li>Reduced CPU and memory pressure</li></ul><h3>3. Removal of .populate()</h3><p>Mongoose .populate():</p><ul><li>Executes extra queries</li><li>Loads full documents</li><li>Limited filtering control</li></ul><p>Aggregation $lookup:</p><ul><li>Server-side execution</li><li>Fine-grained control</li><li>Predictable performance</li></ul><h3>4. Improved Stability and Throughput</h3><ul><li>Lower memory usage</li><li>Faster serialization</li><li>Better concurrency handling</li></ul><h3>Measured Results</h3><ul><li><strong>Response time</strong>: ~3s → <strong>&lt;200ms</strong></li><li>📉 <strong>Payload size</strong>: ~25MB → <strong>~25KB</strong></li><li><strong>Mobile experience</strong>: Better</li><li>💰 <strong>Bandwidth usage</strong>: drastically reduced</li><li>😌 <strong>User experience</strong>: significantly improved</li></ul><p>Optimized a MongoDB-backed Node.js API by replacing Mongoose populate-based queries with a custom aggregation pipeline, reducing response times from ~3 seconds to under 200ms and shrinking response payloads from ~25MB to ~25KB, dramatically improving performance on slow mobile networks.</p><h3>Final Takeaway</h3><p>Performance issues some times come from <strong>data volume</strong>, not computation.</p><p>By:</p><ul><li>Filtering early</li><li>Joining selectively</li><li>Projecting intentionally</li></ul><p>you can unlock massive gains without adding infrastructure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ffce2cfc5e7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the JavaScript Event Loop: A Closer Look into Asynchronous Execution]]></title>
            <link>https://medium.com/@m.ali.ashraf.moh/understanding-the-javascript-event-loop-a-closer-look-into-asynchronous-execution-9f28728be178?source=rss-0028d5320505------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f28728be178</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[asynchronous]]></category>
            <category><![CDATA[event-loop]]></category>
            <dc:creator><![CDATA[Ali Ashraf]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 01:26:36 GMT</pubDate>
            <atom:updated>2025-07-22T01:26:36.273Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/862/1*idUHRlO6taVJl0TQFtYGnA.png" /></figure><p>JavaScript is renowned for its single-threaded nature, meaning it can execute only one piece of code at a time. This characteristic might seem limiting for modern web applications that constantly deal with network requests, user interactions, and complex computations. However, JavaScript achieves its non-blocking, asynchronous capabilities through a sophisticated mechanism known as the <strong>Event Loop</strong>. Far from being a simple queue, the Event Loop is a continuous orchestration process that allows JavaScript to handle multiple tasks efficiently without freezing the user interface.</p><p>This article will demystify the JavaScript Event Loop by breaking down its core components, explaining their interactions, and clarifying the precise order in which asynchronous operations are handled.</p><h3>The Core Components of the Event Loop</h3><p>To truly grasp how JavaScript manages asynchronicity, it’s essential to understand the distinct roles of its key components:</p><ol><li><strong>The Call Stack:</strong> The Call Stack is a Last-In, First-Out (LIFO) data structure where synchronous JavaScript code is executed. When a function is called, it’s pushed onto the stack, and when it returns, it’s popped off. JavaScript can only process one item on the Call Stack at any given moment. If a synchronous operation, such as a long-running loop or a blocking network request, takes too long, it monopolizes the thread, preventing any other code from executing and leading to an unresponsive user interface. This is why the principle of “don’t block the event loop” is paramount.</li><li><strong>Web APIs (Host Environment APIs):</strong> These are functionalities provided by the runtime environment (e.g., the browser or Node.js), not by the core JavaScript engine itself. Web APIs handle asynchronous operations like timers (setTimeout, setInterval), network requests (fetch, XMLHttpRequest), and DOM events (click, load). <br>When JavaScript encounters these operations, it hands them off to the respective Web API, allowing the Call Stack to remain free and continue executing other synchronous code. These external APIs often operate in separate operating system threads, enabling concurrent processing without blocking the main JavaScript thread.</li><li><strong>The Event Loop:</strong> The Event Loop is the continuous process that monitors the Call Stack and the various task queues. Its fundamental role is to push tasks from these queues onto the Call Stack <em>only when the Call Stack is empty</em>. This mechanism ensures that JavaScript’s single thread is never blocked while waiting for asynchronous operations to complete, thereby enabling non-blocking execution and maintaining application responsiveness. <br>It’s crucial to note that the term “Event Loop” is not part of the ECMAScript (JavaScript language) specification but rather exists within the domain of the host executor (e.g., HTML standard for browser libuv for Node.js)</li><li><strong>Task Queues: Macrotasks (Task Queue) vs. Microtasks (Microtask Queue): </strong>The Event Loop manages two primary categories of queues for asynchronous callbacks, each with distinct priorities and behaviors:</li></ol><ul><li><strong>Microtask Queue (Jobs):</strong> This queue holds high-priority asynchronous callbacks. Examples include Promise.then(), Promise.catch(), Promise.finally(), MutationObserver, and functions explicitly queued via queueMicrotask(). In Node.js,process.nextTick() callbacks also reside here, often with even higher priority.</li><li>Microtasks have a <em>higher priority</em> than macrotasks. They are processed <em>completely</em> (all pending microtasks are drained) after the synchronous code finishes execution and before the Event Loop proceeds to the next macrotask or initiates rendering. A critical characteristic is that if a microtask enqueues another microtask, the newly added microtask will also be executed within the <em>same</em> Event Loop tick, prior to any macrotasks. This can lead to “microtask starvation” if not managed carefully, where continuous microtask creation prevents the UI from updating.</li><li><strong>Macrotask Queue (Tasks):</strong> This queue holds lower-priority asynchronous callbacks. Examples include setTimeout(), setInterval(), I/O operations (e.g., file system reads, network requests that are not Promise-based), and DOM events (e.g., click, load).</li><li>Macrotasks have a <em>lower priority</em> compared to microtasks. The Event Loop processes <em>only one</em> macrotask per “tick” after the Call Stack and the entire Microtask Queue are empty. This “one-macrotask-per-tick” model is what enables the browser to perform rendering updates between the execution of macrotasks, thereby preventing UI freezes and maintaining responsiveness. It’s worth noting that while “macrotask” is commonly used, the ECMAScript specification refers to these simply as “tasks”.</li></ul><h3>The Event Loop’s Execution Order: A Precise Dance</h3><p>The precise order of execution within a single “tick” (or iteration) of the Event Loop is fundamental for predicting asynchronous JavaScript behavior:</p><ol><li><strong>Synchronous Code Execution:</strong> All code currently on the Call Stack is executed first, following the LIFO principle.</li><li><strong>Drain Microtask Queue:</strong> Once the Call Stack is empty, the Event Loop completely drains the Microtask Queue. All pending microtasks are executed sequentially until the queue is empty.</li><li><strong>Perform Rendering (Browser Only):</strong> After the microtask queue is empty, in browser environments, the system checks for and performs rendering updates (layout, paint). This typically occurs before the next macrotask is selected, contributing to a smooth user experience.</li><li><strong>Execute One Macrotask:</strong> The Event Loop then selects <em>one</em> task from the Macrotask Queue and pushes it onto the Call Stack for execution.</li><li><strong>Cycle Repeats:</strong> After the single macrotask completes, the Event Loop returns to step 2, continuing the cycle.</li></ol><p>This precise, multi-step execution order explains why, for example, a Promise.resolve().then() callback will always execute before a setTimeout(0) callback, even if the setTimeout is scheduled first.</p><p>Modern asynchronous JavaScript patterns, particularly async/await, are built upon this underlying mechanism. When an await expression is encountered within an async function, the code <em>after</em> the await is effectively pushed to the Microtask Queue, while everything <em>before</em> the await runs synchronously in the current tick. This demonstrates that</p><p>async/await is syntactic sugar leveraging Promises and, by extension, the existing microtask queue mechanism.</p><h3>Common Misconceptions and Nuances</h3><ul><li><strong>setTimeout(0) is not immediate:</strong> While setTimeout(0) instructs the environment to queue a callback as soon as possible, it&#39;s still a macrotask. It will only execute after the current synchronous code and <em>all</em> pending microtasks are drained.</li><li><strong>JavaScript engine is single-threaded, but Web APIs are not:</strong> The core JavaScript engine and its Call Stack are indeed single-threaded. However, Web APIs (or libuv in Node.js) can utilize separate operating system threads to perform their background operations, allowing for concurrency without blocking the main JavaScript thread.</li><li><strong>Node.js Event Loop has phases:</strong> Node.js implements a more complex, phase-based Event Loop, built upon the libuv library. Its distinct phases (Timers, Pending Callbacks, Poll, Check, etc.) provide granular control over task execution, with process.nextTick() callbacks having a special, highest priority, executing between these phases.</li></ul><h3>Conclusion</h3><p>The JavaScript Event Loop is a sophisticated and essential mechanism that underpins the language’s ability to handle asynchronous operations efficiently. By understanding the interplay between the Call Stack, Web APIs, the Microtask Queue, and the Macrotask Queue, developers can write more performant, responsive, and predictable JavaScript applications. Mastering these concepts is crucial for debugging complex asynchronous flows and building robust, non-blocking user experiences.</p><h3>📚 References</h3><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Execution_model">MDN — JS Execution Model</a></li><li>Lydia Hallie — Event Loop Visualized</li><li>Philip Roberts — What the Heck is the Event Loop Anyway?</li></ul><h3>Connect with me!</h3><p><a href="https://x.com/ali_techlog">https://x.com/ali_techlog</a></p><p>#JavaScript #WebDevelopment #AsyncProgramming #Frontend #DevNotes #Sharing #EventLoop</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f28728be178" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JavaScript Event Loop Explained (3 min read)]]></title>
            <link>https://medium.com/@m.ali.ashraf.moh/javascript-event-loop-explained-3-min-read-f46a6270bf52?source=rss-0028d5320505------2</link>
            <guid isPermaLink="false">https://medium.com/p/f46a6270bf52</guid>
            <dc:creator><![CDATA[Ali Ashraf]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 23:46:30 GMT</pubDate>
            <atom:updated>2025-07-22T00:42:16.166Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve ever been wondering about why setTimeout(fn, 0) runs <em>after</em> a Promise.then() — and want to know — read along 📖.</p><p>JavaScript’s <strong>event loop</strong> behavior isn’t about speed — it’s about <strong>task types</strong> and <strong>execution priority. Understanding this will enable YOU to write better code that makes the web page feels snappy ⚡️, predictable behavior and avoid perceptible lag/choppy web apps😒</strong></p><h3>🔸 The Core Concepts</h3><p>Broadly speaking, JavaScript has:</p><ul><li>A <strong>Call Stack</strong> — executes one function at a time.</li><li><strong>Web APIs</strong> — like timers, fetch, DOM events (provided by the browser/Node).</li><li><strong>Task Queues</strong> — to handle callbacks.</li><li>And the <strong>Event Loop</strong> — the system that coordinates when queued tasks get executed.</li></ul><h3>🔹 Two Types of Queues</h3><h4>1. Macrotask Queue</h4><p>Includes:</p><ul><li>setTimeout</li><li>setInterval</li><li>fetch callbacks</li><li>UI Events</li></ul><h4>2. Microtask Queue</h4><p>Includes:</p><ul><li>Promise.then()</li><li>queueMicrotask()</li><li>MutationObserver</li></ul><p><strong>Order of Execution</strong>:</p><ol><li>JavaScript runs synchronous code on the call stack.</li><li>After the stack is clear, it:</li></ol><ul><li>Runs <strong>all microtasks</strong></li><li>Then executes the <strong>next macrotask</strong></li><li>Then paints/renders (if needed)</li><li>Then repeats</li></ul><h3>🧪 Example 1</h3><pre>console.log(&#39;1&#39;);<br><br>setTimeout(() =&gt; console.log(&#39;2&#39;), 0);<br><br>Promise.resolve().then(() =&gt; {<br>  console.log(&#39;3&#39;);<br>});<br><br>console.log(&#39;4&#39;);</pre><p><strong>Why?</strong></p><ul><li>1 and 4 are synchronous → run first.</li><li>Promise.then() → microtask → runs <em>after</em> the current stack → logs 3.</li><li>setTimeout → macrotask → waits until microtasks finish → logs 2</li></ul><h3>🔁 Event Loop Cycle Recap</h3><p>Each loop cycle:</p><ol><li>Pick <strong>one macrotask</strong> → push onto the stack</li><li>Once the stack is empty:<br>Run <strong>all microtasks</strong> (before touching next macrotask)</li><li>Repeat</li></ol><p>This is why flooding the microtask queue (e.g., infinite Promise.then) can <strong>block UI rendering</strong> — the browser never gets a breather.</p><h3>🧪 Example 2 to Solidify — fetch() vs Promise.then() vs setTimeout</h3><pre>console.log(&#39;Start&#39;);<br><br>setTimeout(() =&gt; {<br>  console.log(&#39;setTimeout&#39;);<br>}, 0);<br><br>fetch(&#39;https://jsonplaceholder.typicode.com/todos/1&#39;)<br>  .then(() =&gt; console.log(&#39;fetch then&#39;));<br><br>Promise.resolve().then(() =&gt; console.log(&#39;Promise then&#39;));<br><br>console.log(&#39;End&#39;);</pre><h3>🔍 Why This Happens:</h3><ol><li>console.log(&#39;Start&#39;) → runs immediately (sync)</li><li>setTimeout(...) → queued in <strong>macrotask queue</strong></li><li>fetch(...).then(...) → response callback is queued in <strong>microtask queue</strong>, <em>but only after the response returns</em></li><li>Promise.resolve().then(...) → queued in <strong>microtask queue</strong> immediately</li><li>console.log(&#39;End&#39;) → runs immediately</li><li>Now the call stack is empty, so:<br>Event loop runs <strong>microtasks</strong>:</li><li>Promise then logs first</li><li>If fetch response is ready, its .then() logs fetch then</li><li>Then the next <strong>macrotask</strong>: setTimeout logs</li></ol><h3>Visual Diagram of the Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m5oE9tN4F7wM5H6v2ZOSPQ.png" /></figure><h3>💡 Why Promise.then() logs before fetch().then() (even though both use microtasks)</h3><h3>🔍 Explanation:</h3><ol><li><strong>Promise.resolve().then(...)</strong> is <strong>synchronous in creation</strong> and its .then() is immediately pushed into the <strong>microtask queue</strong>.</li><li><strong>fetch(...)</strong> is asynchronous:<br>The HTTP request is sent to the browser’s <strong>Web API</strong> layer.<br>When the response arrives (later, via the network), <strong>only then</strong> is its .then() callback scheduled as a <strong>microtask</strong>.<br>So it doesn’t go into the microtask queue right away — only <strong>after</strong> the fetch resolves.</li><li>Therefore:</li></ol><ul><li>Promise then is already in the <strong>current</strong> microtask queue.</li><li>fetch then enters the <strong>microtask queue of a later event loop tick</strong> — once the HTTP response is back.</li></ul><h3>Summary</h3><ul><li>JS is single-threaded → one call stack</li><li>Async work → offloaded to Web APIs</li><li>Jobs (callbacks) → added to queues</li><li>Microtasks (Promises) run before Macrotasks (setTimeout, fetch)</li><li><strong>Event loop runs: Sync → Microtasks → Macrotask → Repeat</strong></li></ul><h3>📚 References</h3><ul><li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Execution_model">MDN — JS Execution Model</a></li><li>Lydia Hallie — Event Loop Visualized</li><li>Philip Roberts — What the Heck is the Event Loop Anyway?</li></ul><h3>Connect with me!</h3><p><a href="https://x.com/ali_techlog">https://x.com/ali_techlog</a></p><p>#JavaScript #WebDevelopment #AsyncProgramming #Frontend #DevNotes #LearningInPublic #EventLoop</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f46a6270bf52" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>