From 140263ce599a6729ed70b8b642be67c982604d3b Mon Sep 17 00:00:00 2001 From: athikha-faiz_infosys Date: Sat, 18 Oct 2025 13:30:16 +0530 Subject: [PATCH 1/3] HTTP requests Fixes #609 --- README.md | 15 ++++++++ event-loop-demo.html | 88 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 event-loop-demo.html diff --git a/README.md b/README.md index 924a02f7..58271fc4 100644 --- a/README.md +++ b/README.md @@ -425,6 +425,21 @@ The Event Loop is a critical part of JavaScript's concurrency model, ensuring no **[⬆ Back to Top](#table-of-contents)** +### Event Loop demo (interactive) + +There is a small interactive demo included in this repository to visualize microtasks vs macrotasks ordering in the browser. + +- File: `event-loop-demo.html` +- How to open: double-click the file in your file manager or open it in your browser. From the repo root you can also run a simple static server, for example with Python 3: + +```powershell +# from repository root +python -m http.server 8080; # then open http://localhost:8080/event-loop-demo.html +``` + +The demo logs messages to the page and to the browser console showing the expected ordering between synchronous code, microtasks (Promises / async / MutationObserver) and macrotasks (setTimeout). + + --- ## 10. setTimeout, setInterval and requestAnimationFrame diff --git a/event-loop-demo.html b/event-loop-demo.html new file mode 100644 index 00000000..6298350b --- /dev/null +++ b/event-loop-demo.html @@ -0,0 +1,88 @@ + + + + + + Event Loop: Microtasks vs Macrotasks Demo + + + +

Event Loop Demo

+

This page demonstrates ordering between microtasks (Promises / async) and macrotasks (setTimeout). Open the developer console to see the same logs.

+ + +
+ + + + + + + From eb8b94560cbd121463fee4ddb4826421412a399e Mon Sep 17 00:00:00 2001 From: athikha Date: Sat, 18 Oct 2025 19:59:54 +0530 Subject: [PATCH 2/3] HTTP requests Fixes #609 --- event-loop-demo.html | 173 ++++++++++++++++++++++++++++++++++--------- 1 file changed, 140 insertions(+), 33 deletions(-) diff --git a/event-loop-demo.html b/event-loop-demo.html index 6298350b..72695b34 100644 --- a/event-loop-demo.html +++ b/event-loop-demo.html @@ -5,83 +5,190 @@ Event Loop: Microtasks vs Macrotasks Demo -

Event Loop Demo

-

This page demonstrates ordering between microtasks (Promises / async) and macrotasks (setTimeout). Open the developer console to see the same logs.

- - +

Event Loop: Message Queue and Microtasks Demo

+

This demo illustrates how the Event Loop processes tasks from the Message Queue (macrotasks) and Microtask Queue. The Message Queue handles setTimeout callbacks and DOM events, while the Microtask Queue processes Promises and async/await operations with higher priority.

+ +
+ + + + +
+
From 002a19608dd4ba3f89165fb3cdc2957cfec8c583 Mon Sep 17 00:00:00 2001 From: athikha Date: Sat, 18 Oct 2025 20:12:02 +0530 Subject: [PATCH 3/3] Add Event Loop Implementation - Create interactive demo of JavaScript Event Loop - Implement Message Queue and Microtask Queue handling - Add visual execution flow with timestamps - Include DOM event examples - Demonstrate Promise and async/await behavior Resolves the implementation of Event Loop demonstration showing: - Task Queue (Message Queue) operations - Microtask queue priority - Event Loop execution order - Asynchronous operation handling --- event-loop-demo.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/event-loop-demo.html b/event-loop-demo.html index 72695b34..3123f353 100644 --- a/event-loop-demo.html +++ b/event-loop-demo.html @@ -3,7 +3,7 @@ - Event Loop: Microtasks vs Macrotasks Demo + Event Loop: Message Queue and Microtasks Demo