An interactive tool for visualizing and learning JavaScript Event Loop principles. Modern React web application with beautiful UI that helps developers understand JavaScript asynchronicity, execution order, and interaction between Call Stack, Web APIs, Microtask and Task (Callback) queues.
πΊπ¦ Π£ΠΊΡΠ°ΡΠ½ΡΡΠΊΠ° Π²Π΅ΡΡΡΡ
- Modern design with shadcn/ui components and responsive sidebar
- Dark and light theme with automatic switching
- Fully responsive design for mobile, tablets and desktops
- Smart sidebar:
- Automatically collapses on narrow screens (icons only)
- Expands on wide screens with full text
- Toggle with
Bkey
- Smooth animations and state transitions
- Intuitive interface with tooltips and hints
- Clean UI - empty sections auto-hide
- Visualization of Call Stack, Web APIs, Microtask Queue, Task Queue, Stack and Heap memory
- Step-by-step execution with detailed explanations for each action
- 5 built-in examples:
- ποΈ Memory and Variables - Stack and Heap demonstration (primitives, objects, functions)
- β±οΈ setTimeout - basic async code handling
- β‘ Promise vs setTimeout - difference between microtask and macrotask
- π Complex Example - nested Promises and setTimeout
- π Fetch API - network requests and handling
- Two execution modes: automatic and manual
- Action history to track all execution steps
- Code display with active line highlighting
- Interactive sidebar with:
- Quick example launch
- Clear buttons (full and selective)
- Event Loop reference guide
- Keyboard shortcuts: Space, 0-4, A, B, C, Esc for quick navigation
- English (default, auto-detected from browser)
- Ukrainian (ΠΏΠΎΠ²Π½Π° ΠΏΡΠ΄ΡΡΠΈΠΌΠΊΠ° ΡΠΊΡΠ°ΡΠ½ΡΡΠΊΠΎΡ ΠΌΠΎΠ²ΠΈ)
- Language switcher in the header for instant language switching
- Language preference persists across page reloads (localStorage)
- All interface elements, examples, and explanations are fully translated
# Clone the repository
git clone https://github.com/vitalii4reva/visual-js-event-loop.git
cd visual-js-event-loop
# Install dependencies
pnpm install
# Start dev server
pnpm devOpen http://localhost:3000 in your browser.
# Create production build
pnpm build
# Preview production version locally
pnpm previewBuild output will be in the dist/ directory
- βοΈ React 19 - UI framework
- π TypeScript 5.9 - Type safety
- π¨ Tailwind CSS 3.4 - Styling
- π§© shadcn/ui - UI components
- β‘ Vite 6 - Build tool
- π Lucide React - Icons
- π next-themes - Theme management
src/
βββ components/ # React components
β βββ ui/ # shadcn/ui components (sidebar, button, card...)
β βββ layout/ # Header, ExamplesSidebar, KeyboardShortcuts
β βββ event-loop/ # Event Loop Visualization
β β βββ CallStack.tsx
β β βββ WebAPIs.tsx
β β βββ MicrotaskQueue.tsx
β β βββ TaskQueue.tsx
β β βββ Memory.tsx # Heap memory
β β βββ StackVariables.tsx # Stack frames
β βββ controls/ # StepControls
β βββ panels/ # HistoryPanel
βββ hooks/ # Custom React hooks
β βββ useEventLoop.ts
β βββ useStepExecution.ts
β βββ useKeyboardShortcuts.ts
β βββ use-mobile.tsx
βββ context/ # React Context (ThemeProvider, LanguageProvider)
βββ lib/ # Utilities and examples
β βββ examples.ts # 5 built-in examples
β βββ utils.ts
βββ types/ # TypeScript types
β βββ eventLoop.ts
β βββ memory.ts
βββ i18n/ # Translations (en, uk)
βββ App.tsx # Main component
βββ main.tsx # Entry point
The visualizer demonstrates JavaScript Event Loop operation and memory management:
- Call Stack: Shows functions currently executing.
- Web APIs: Displays asynchronous operations running in background.
- Microtask Queue: High-priority task queue (Promise).
- Task Queue: Regular task queue (setTimeout, setInterval).
- Stack Variables: Shows local variables in Stack Frames.
- Memory (Heap): Shows objects, functions, and other complex data types.
- Event Loop: Constantly checks stack and queue state, following priorities.
- Execute all synchronous code in Call Stack
- Check if Call Stack is empty
- Process ALL microtasks from Microtask Queue
- Take ONE task from Task Queue
- Repeat from step 1
- Select an example in the left sidebar (or keys 0-4):
- 0 - Memory and Variables (Stack & Heap)
- 1 - setTimeout demonstration
- 2 - Promise vs setTimeout
- 3 - Complex example
- 4 - Fetch API
- Execution mode:
- Manual mode: Click "Next step" or Space/Enter
- Auto mode: Automatic execution with 1.5 sec delay (key A)
- Observe:
- Call Stack - active functions
- Web APIs - asynchronous operations
- Microtask Queue - high-priority tasks (Promise)
- Task Queue - regular tasks (setTimeout)
- Memory (Heap) - objects and functions (appear in example 0)
- Track action history in the right panel
- Control sidebar - key B or button in header
- Keyboard shortcuts - Click keyboard icon in header for full list
We encourage contributions to the project!
- π Report a bug via Issues
- β¨ Suggest a new feature
- π Improve documentation
- π Add translation to another language
- π» Submit a Pull Request
- Fork the repository
- Create a branch:
git checkout -b feature/amazing-feature - Make changes and commit:
git commit -m 'Add amazing feature' - Push to branch:
git push origin feature/amazing-feature - Open a Pull Request
-
Add Examples 3 and 4 (complex example, Fetch API)β -
Keyboard shortcuts (Space, numbers, A, C)β -
Responsive sidebar with shadcn/uiβ -
Stack and Heap memory visualizationβ -
Memory exampleβ -
Multi-language support (EN, UK)β - Interactive mode for creating custom examples
- Export execution history
- Additional languages (PL, etc.)
- Animations with Framer Motion
- Touch gestures for mobile
Project is optimized for search engines:
- β Structured Data (JSON-LD) with author information
- β Open Graph tags for social networks
- β Meta tags for search engines
- β Responsive Design
- β Performance optimization
- β Accessibility (ARIA labels)
- β Humans.txt and Robots.txt
- β Sitemap.xml
This project is licensed under the MIT License - see the LICENSE file for details.
Vitalii Petrenko
- π vitalii4reva.com
- π§ vitalii4reva@gmail.com
- πΌ LinkedIn
- React for an amazing UI framework
- shadcn/ui for beautiful components
- Vite for a fast build tool
- Lucide for quality icons
If this project was helpful, give it a β on GitHub!
Made with β€οΈ in Ukraine πΊπ¦
